Skip to content

Commit

Permalink
Drupal 9 compatibility fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Vladyslav Solodovnyk committed Sep 20, 2021
1 parent 692f453 commit 38cfd21
Show file tree
Hide file tree
Showing 46 changed files with 201 additions and 222 deletions.
17 changes: 4 additions & 13 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,17 @@
"license": "GPL-2.0+",
"require": {
"cweagans/composer-patches": "~1.0",
"drupal/panelizer": "4.1",
"drupal/panelizer": "^4.4",
"drupal/panels": "^4.6",
"drupal/ckeditor_font": "^1.0",
"drupal/dynamic_entity_reference": "^1.7",
"drupal/duration_field": "^1.6"
"drupal/duration_field": "^2.0"
},
"minimum-stability": "dev",
"repositories": [
{
"type": "composer",
"url": "https://packages.drupal.org/8"
}
],
"extra": {
"patches": {
"drupal/duration_field": {
"2978206 - Undefined index: #states in drupal_process_states()": "https://www.drupal.org/files/issues/2018-06-08/2978206-2.patch"
},
"drupal/panels": {
"2895962 - Add \"methods\" to Panels IPE routes to support Drupal 8.4.0 / Symfony 3.x": "https://www.drupal.org/files/issues/panels-deprecate-method.patch"
}
}
}
]
}
3 changes: 2 additions & 1 deletion modules/ds_datetime_range/ds_datetime_range.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: Digital Signage Datetime Range
type: module
description: Datetime Range cusomizations.
core: 8.x
core_version_requirement: ^8 || ^9
package: "OpenY: Digital Signage"
dependencies:
- datetime_range
- drupal:datetime_range
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ name: Open Y Digital Signage Alerts
type: module
description: Digital Signage Alerts.
core: 8.x
core_version_requirement: ^8 || ^9
package: "OpenY: Digital Signage"
dependencies:
- openy_digital_signage_screen
- openy_node_alert
- openy_node_alert:openy_node_alert
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ name: OpenY Digital Signage GroupEx Pro Classes Schedule
type: module
description: OpenY Digital Signage GroupEx Pro Classes Schedule.
core: 8.x
core_version_requirement: ^8 || ^9
package: "OpenY: Digital Signage"
dependencies:
- openy_digital_signage_classes_schedule
- openy_digital_signage_room
- ymca_mappings
- ymca_groupex
- openy_digital_signage_room:openy_digital_signage_room
- ymca_mappings:ymca_mappings
- ymca_groupex:ymca_groupex
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Url;
use Drupal\datetime\Plugin\Field\FieldType\DateTimeItemInterface;
use Drupal\openy_digital_signage_groupex_schedule\OpenYSessionsGroupExFetcher;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
Expand Down Expand Up @@ -47,7 +48,7 @@ public static function create(ContainerInterface $container) {
public function importSessions() {
$locations = $this->groupExFetcher->getLocations();
if (empty($locations)) {
drupal_set_message($this->t('Locations are not set in GroupEx Pro settings. Please specify locations you want to use and try again.'), 'error');
$this->messenger()->addError($this->t('Locations are not set in GroupEx Pro settings. Please specify locations you want to use and try again.'));
$url = new Url('entity.openy_ds_classes_session.collection');
return new RedirectResponse($url->toString());
}
Expand Down Expand Up @@ -113,7 +114,7 @@ public static function checkDeleted(&$context) {
$context['results']['to_be_deleted'] = [];
$date = new \DateTime();
$date->setTime(0, 0, 0);
$context['sandbox']['datetime'] = $date->format(DATETIME_DATETIME_STORAGE_FORMAT);
$context['sandbox']['datetime'] = $date->format(DateTimeItemInterface::DATETIME_STORAGE_FORMAT);

$query = \Drupal::entityQuery('openy_ds_classes_groupex_session')
->condition('date_time.value', $context['sandbox']['datetime'], '>')
Expand Down Expand Up @@ -268,7 +269,7 @@ public static function finishBatch($success, $results, $operations) {
else {
$message = t('Finished with an error.');
}
drupal_set_message($message);
\Drupal::messenger()->addMessage($message);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Drupal\openy_digital_signage_groupex_schedule;

use Drupal\datetime\Plugin\Field\FieldType\DateTimeItemInterface;
use Drupal\ymca_groupex\GroupexRequestTrait;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
Expand Down Expand Up @@ -147,7 +148,7 @@ public function checkDeleted($feed, $location_id) {

$date = new \DateTime();
$date->setTime(0, 0, 0);
$formatted = $date->format(DATETIME_DATETIME_STORAGE_FORMAT);
$formatted = $date->format(DateTimeItemInterface::DATETIME_STORAGE_FORMAT);

/* @var \Drupal\ymca_mappings\Entity\Mapping $location */
$location = $this->locationRepository->load($location_id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ name: OpenY Digital Signage Personify Classes Schedule
type: module
description: OpenY Digital Signage Personify Schedule.
core: 8.x
core_version_requirement: ^8 || ^9
package: "OpenY: Digital Signage"
dependencies:
- openy_digital_signage_classes_schedule
- openy_digital_signage_room
- ymca_mappings
- ymca_personify
- openy_digital_signage_room:openy_digital_signage_room
- ymca_mappings:ymca_mappings
- ymca_personify:ymca_personify
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use Drupal\Core\Link;
use Drupal\Core\Url;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\datetime\Plugin\Field\FieldType\DateTimeItemInterface;
use Drupal\openy_digital_signage_classes_schedule\Entity\OpenYClassesSession;
use Drupal\openy_digital_signage_personify_schedule\Entity\OpenYClassesPersonifySession;
use Drupal\openy_digital_signage_room\Entity\OpenYRoom;
Expand Down Expand Up @@ -178,8 +179,8 @@ function openy_digital_signage_personify_build_session_datetime(OpenYClassesPers
$end_date->setTimezone(new \DateTimeZone('UTC'));

return [
'start' => $start_date->format(DATETIME_DATETIME_STORAGE_FORMAT),
'end' => $end_date->format(DATETIME_DATETIME_STORAGE_FORMAT),
'start' => $start_date->format(DateTimeItemInterface::DATETIME_STORAGE_FORMAT),
'end' => $end_date->format(DateTimeItemInterface::DATETIME_STORAGE_FORMAT),
];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Url;
use Drupal\datetime\Plugin\Field\FieldType\DateTimeItemInterface;
use Drupal\openy_digital_signage_personify_schedule\Entity\OpenYClassesPersonifySession;
use Drupal\openy_digital_signage_personify_schedule\OpenYSessionsPersonifyFetcher;
use Symfony\Component\DependencyInjection\ContainerInterface;
Expand Down Expand Up @@ -48,7 +49,7 @@ public static function create(ContainerInterface $container) {
public function importSessions() {
$locations = $this->personifyFetcher->getLocations();
if (empty($locations)) {
drupal_set_message($this->t('Locations are not set in Personify settings. Please specify locations you want to use and try again.'), 'error');
$this->messenger()->addError($this->t('Locations are not set in Personify settings. Please specify locations you want to use and try again.'));
$url = new Url('entity.openy_ds_classes_session.collection');
return new RedirectResponse($url->toString());
}
Expand Down Expand Up @@ -112,7 +113,7 @@ public static function checkDeleted(&$context) {
$context['results']['to_be_deleted'] = [];
$date = new \DateTime();
$date->setTimestamp(REQUEST_TIME);
$context['sandbox']['datetime'] = $date->format(DATETIME_DATETIME_STORAGE_FORMAT);
$context['sandbox']['datetime'] = $date->format(DateTimeItemInterface::DATETIME_STORAGE_FORMAT);

$query = \Drupal::entityQuery('openy_ds_class_personify_session')
->condition('date.value', $context['sandbox']['datetime'], '<')
Expand Down Expand Up @@ -262,7 +263,7 @@ public static function finishBatch($success, $results, $operations) {
else {
$message = t('Finished with an error.');
}
drupal_set_message($message);
\Drupal::messenger()->addMessage($message);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\datetime\Plugin\Field\FieldType\DateTimeItemInterface;
use Drupal\openy_digital_signage_personify_schedule\Entity\OpenYClassesPersonifySession;
use Drupal\ymca_mappings\LocationMappingRepository;
use Drupal\ymca_personify\PersonifyApi;
Expand Down Expand Up @@ -156,7 +157,7 @@ public function checkDeleted($feed) {

$date = new \DateTime();
$date->setTimestamp(REQUEST_TIME);
$formatted = $date->format(DATETIME_DATETIME_STORAGE_FORMAT);
$formatted = $date->format(DateTimeItemInterface::DATETIME_STORAGE_FORMAT);

$locations = $this->getLocations();
if (empty($locations)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ name: Digital Signage Classes Schedule
type: module
description: Digital Signage Classes Schedule.
core: 8.x
core_version_requirement: ^8 || ^9
package: "OpenY: Digital Signage"
dependencies:
- ds_datetime_range
- openy_digital_signage_room
- ds_datetime_range:ds_datetime_range
- openy_digital_signage_room:openy_digital_signage_room
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
services:
openy_digital_signage_classes_schedule.manager:
class: Drupal\openy_digital_signage_classes_schedule\OpenYClassesScheduleManager
arguments: ['@entity.manager', '@entity.query', '@logger.factory']
arguments: ['@entity_type.manager', '@logger.factory']
openy_digital_signage_classes_schedule.cron:
class: Drupal\openy_digital_signage_classes_schedule\OpenYClassesScheduleCron
arguments: ['@config.factory', '@entity_type.manager', '@logger.factory']
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ public function save(array $form, FormStateInterface $form_state) {

switch ($status) {
case SAVED_NEW:
drupal_set_message($this->t('Digital Signage Classes Session %label has been created.', [
$this->messenger()->addMessage($this->t('Digital Signage Classes Session %label has been created.', [
'%label' => $entity->label(),
]));
break;

default:
drupal_set_message($this->t('Digital Signage Classes Session %label has been saved.', [
$this->messenger()->addMessage($this->t('Digital Signage Classes Session %label has been saved.', [
'%label' => $entity->label(),
]));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function save(array $form, FormStateInterface $form_state) {
switch ($status) {
default:
case SAVED_NEW:
drupal_set_message($this->t('Digital Signage Classes Session %label has been overridden.', [
$this->messenger()->addMessage($this->t('Digital Signage Classes Session %label has been overridden.', [
'%label' => $this->entity->label(),
]));
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Drupal\Core\Entity\EntityTypeManager;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Entity\Query\QueryFactory;
use Drupal\Core\Logger\LoggerChannelFactoryInterface;

/**
Expand All @@ -25,13 +24,6 @@ class OpenYClassesScheduleManager implements OpenYClassesScheduleManagerInterfac
*/
const STORAGE = 'openy_ds_classes_session';

/**
* The query factory.
*
* @var QueryFactory
*/
protected $entityQuery;

/**
* The entity type manager.
*
Expand All @@ -56,8 +48,7 @@ class OpenYClassesScheduleManager implements OpenYClassesScheduleManagerInterfac
/**
* Constructor.
*/
public function __construct(EntityTypeManagerInterface $entity_type_manager, QueryFactory $entity_query, LoggerChannelFactoryInterface $logger_factory) {
$this->entityQuery = $entity_query;
public function __construct(EntityTypeManagerInterface $entity_type_manager, LoggerChannelFactoryInterface $logger_factory) {
$this->entityTypeManager = $entity_type_manager;
$this->logger = $logger_factory->get(self::CHANNEL);
$this->storage = $this->entityTypeManager->getStorage(self::STORAGE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ name: Open Y Digital Signage Playlists
type: module
description: Add Playlists to Open Y Digital Signage.
core: 8.x
core_version_requirement: ^8 || ^9
package: "OpenY: Digital Signage"
dependencies:
- openy_digital_signage_schedule
- datetime
- duration_field
- drupal:datetime
- drupal:duration_field
- drupal:media (>= 8.4)
- openy_media_image
- entity_browser
- openy_digital_signage_schedule
- openy_digital_signage_screen
- openy_ds_media_library
- openy_media_image:openy_media_image
- entity_browser:entity_browser
- openy_digital_signage_schedule:openy_digital_signage_schedule
- openy_digital_signage_screen:openy_digital_signage_screen
- openy_ds_media_library:openy_ds_media_library
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public function getItemType() {
public function getExpireStatus() {
$date_end = $this->get('date_end')->date;
$time_end = $this->get('time_end')->date;
$default_timezone = drupal_get_user_timezone();
$default_timezone = date_default_timezone_get();
$current_date = new DrupalDateTime('now', $default_timezone);

if (!$date_end) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Datetime\DrupalDateTime;
use Drupal\Core\Url;
use Drupal\datetime\Plugin\Field\FieldType\DateTimeItemInterface;

/**
* Provides a view builder for OpenY Digital Signage Playlist entities.
Expand All @@ -25,7 +26,7 @@ public function view(EntityInterface $entity, $view_mode = 'full', $langcode = N

$settings = [
'digital_signage_playlist' => [
'timezone' => drupal_get_user_timezone(),
'timezone' => date_default_timezone_get(),
],
];

Expand Down Expand Up @@ -102,24 +103,25 @@ public static function getPlaylistItemsRecursive(EntityInterface $playlist, arra
}
}

$duration = new \DateInterval($playlist_item->duration->value);
$duration_service = \Drupal::service('duration_field.service');
$duration = $duration_service->getDateIntervalFromDurationString($playlist_item->duration->seconds);
$duration_seconds = $duration->s + $duration->i * 60 + $duration->h * 3600;

$date_start = $playlist_item->date_start->isEmpty() ? '' : $playlist_item->date_start->value;
$date_end = $playlist_item->date_end->isEmpty() ? '' : $playlist_item->date_end->value;

$time_start = '';
if (!$playlist_item->time_start->isEmpty()) {
$date_time = DrupalDateTime::createFromFormat(DATETIME_DATETIME_STORAGE_FORMAT, $playlist_item->time_start->value, 'UTC');
$date_time->setTimezone(timezone_open(drupal_get_user_timezone()));
$date_time = DrupalDateTime::createFromFormat(DateTimeItemInterface::DATETIME_STORAGE_FORMAT, $playlist_item->time_start->value, 'UTC');
$date_time->setTimezone(timezone_open(date_default_timezone_get()));
$time_start = $date_time->format('H:i:s');
}

$time_end = '';
$playlist_item->time_end->value;
if (!$playlist_item->time_end->isEmpty()) {
$date_time = DrupalDateTime::createFromFormat(DATETIME_DATETIME_STORAGE_FORMAT, $playlist_item->time_end->value, 'UTC');
$date_time->setTimezone(timezone_open(drupal_get_user_timezone()));
$date_time = DrupalDateTime::createFromFormat(DateTimeItemInterface::DATETIME_STORAGE_FORMAT, $playlist_item->time_end->value, 'UTC');
$date_time->setTimezone(timezone_open(date_default_timezone_get()));
$time_end = $date_time->format('H:i:s');
}

Expand Down
Loading

0 comments on commit 38cfd21

Please sign in to comment.