From c040d3c15d23672146f1822bc99786c828ab68c8 Mon Sep 17 00:00:00 2001 From: Vladyslav Solodovnyk Date: Thu, 9 Sep 2021 15:56:01 +0300 Subject: [PATCH] Drupal 9 compatibility fixes. --- composer.json | 17 +++-------- ...ital_signage_classes_schedule.services.yml | 2 +- .../src/OpenYClassesScheduleManager.php | 11 +------- .../Form/OpenYPlaylistAssignScreenForm.php | 28 +++++++++---------- .../src/Form/OpenYPlaylistForm.php | 15 +++++++--- .../OpenYDigitalSignageBlockPlaylist.php | 8 +++--- .../openy_digital_signage_room.services.yml | 2 +- ...peny_digital_signage_schedule.services.yml | 2 +- .../src/OpenYScheduleManager.php | 24 ++++------------ .../openy_digital_signage_screen.services.yml | 2 +- .../src/Form/OpenYScreenAddForm.php | 20 +++++++------ .../src/OpenYScreenManager.php | 24 ++++------------ .../openy_ds_pef_schedule.services.yml | 2 +- .../src/OpenYPEFScheduleManager.php | 23 +++++++-------- 14 files changed, 71 insertions(+), 109 deletions(-) diff --git a/composer.json b/composer.json index eb632de..27c2f3e 100644 --- a/composer.json +++ b/composer.json @@ -6,10 +6,11 @@ "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": [ @@ -17,15 +18,5 @@ "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" - } - } - } + ] } diff --git a/modules/openy_digital_signage_classes_schedule/openy_digital_signage_classes_schedule.services.yml b/modules/openy_digital_signage_classes_schedule/openy_digital_signage_classes_schedule.services.yml index bf94d59..cf0fd25 100644 --- a/modules/openy_digital_signage_classes_schedule/openy_digital_signage_classes_schedule.services.yml +++ b/modules/openy_digital_signage_classes_schedule/openy_digital_signage_classes_schedule.services.yml @@ -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'] diff --git a/modules/openy_digital_signage_classes_schedule/src/OpenYClassesScheduleManager.php b/modules/openy_digital_signage_classes_schedule/src/OpenYClassesScheduleManager.php index bf1446b..1db0b49 100644 --- a/modules/openy_digital_signage_classes_schedule/src/OpenYClassesScheduleManager.php +++ b/modules/openy_digital_signage_classes_schedule/src/OpenYClassesScheduleManager.php @@ -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; /** @@ -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. * @@ -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); diff --git a/modules/openy_digital_signage_playlist/src/Form/OpenYPlaylistAssignScreenForm.php b/modules/openy_digital_signage_playlist/src/Form/OpenYPlaylistAssignScreenForm.php index ddb4090..ee367b0 100644 --- a/modules/openy_digital_signage_playlist/src/Form/OpenYPlaylistAssignScreenForm.php +++ b/modules/openy_digital_signage_playlist/src/Form/OpenYPlaylistAssignScreenForm.php @@ -7,7 +7,7 @@ use Drupal\Core\Ajax\AjaxResponse; use Drupal\Core\Ajax\RedirectCommand; use Drupal\Core\Database\Connection; -use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\Entity\EntityRepositoryInterface; use Drupal\Core\Entity\EntityTypeBundleInfoInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Render\RendererInterface; @@ -25,8 +25,8 @@ class OpenYPlaylistAssignScreenForm extends OpenYScheduleItemForm { /** * Constructors a OpenYPlaylistAssignScreenForm object. * - * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager - * The entity manager service. + * @param \Drupal\Core\Entity\EntityRepositoryInterface $entity_repository + * The entity repository. * @param \Drupal\Core\Entity\EntityTypeBundleInfoInterface $entity_type_bundle_info * The entity type bundle info. * @param \Drupal\Component\Datetime\TimeInterface $time @@ -36,8 +36,8 @@ class OpenYPlaylistAssignScreenForm extends OpenYScheduleItemForm { * @param \Drupal\Core\Render\RendererInterface $renderer * The renderer service. */ - public function __construct(EntityManagerInterface $entity_manager, EntityTypeBundleInfoInterface $entity_type_bundle_info, TimeInterface $time, Connection $database, RendererInterface $renderer) { - parent::__construct($entity_manager, $entity_type_bundle_info, $time); + public function __construct(EntityRepositoryInterface $entity_repository, EntityTypeBundleInfoInterface $entity_type_bundle_info, TimeInterface $time, Connection $database, RendererInterface $renderer) { + parent::__construct($entity_repository, $entity_type_bundle_info, $time); $this->database = $database; $this->renderer = $renderer; @@ -45,7 +45,7 @@ public function __construct(EntityManagerInterface $entity_manager, EntityTypeBu public static function create(ContainerInterface $container) { return new static( - $container->get('entity.manager'), + $container->get('entity.repository'), $container->get('entity_type.bundle.info'), $container->get('datetime.time'), $container->get('database'), @@ -123,10 +123,10 @@ public function validateForm(array &$form, FormStateInterface $form_state) { // In the first step, we check the intersection of the selected time // interval with the interval of the current Schedule item, and then // conversely for determine all intersections of time intervals. - if ($wd_start_time >= $wd_start_time_slot && $wd_start_time <= $wd_end_time_slot || - $wd_end_time >= $wd_start_time_slot && $wd_end_time <= $wd_end_time_slot || - $wd_start_time_slot >= $wd_start_time && $wd_start_time_slot <= $wd_end_time || - $wd_end_time_slot >= $wd_start_time && $wd_end_time_slot <= $wd_end_time) { + if (($wd_start_time >= $wd_start_time_slot && $wd_start_time <= $wd_end_time_slot) || + ($wd_end_time >= $wd_start_time_slot && $wd_end_time <= $wd_end_time_slot) || + ($wd_start_time_slot >= $wd_start_time && $wd_start_time_slot <= $wd_end_time) || + ($wd_end_time_slot >= $wd_start_time && $wd_end_time_slot <= $wd_end_time)) { // If dates are specified in the selected and current Schedule item, // they should also be checked for intersection. @@ -134,10 +134,10 @@ public function validateForm(array &$form, FormStateInterface $form_state) { $start_date_slot = $time_slot->date__value; $end_date_slot = $time_slot->date__end_value; - if ($start_date >= $start_date_slot && $start_date <= $end_date_slot || - $end_date >= $start_date_slot && $end_date <= $end_date_slot || - $start_date_slot >= $start_date && $start_date_slot <= $end_date || - $end_date_slot >= $start_date && $end_date_slot <= $end_date) { + if (($start_date >= $start_date_slot && $start_date <= $end_date_slot) || + ($end_date >= $start_date_slot && $end_date <= $end_date_slot) || + ($start_date_slot >= $start_date && $start_date_slot <= $end_date) || + ($end_date_slot >= $start_date && $end_date_slot <= $end_date)) { $isUsed = TRUE; break; diff --git a/modules/openy_digital_signage_playlist/src/Form/OpenYPlaylistForm.php b/modules/openy_digital_signage_playlist/src/Form/OpenYPlaylistForm.php index e4c1ce5..e5897f9 100644 --- a/modules/openy_digital_signage_playlist/src/Form/OpenYPlaylistForm.php +++ b/modules/openy_digital_signage_playlist/src/Form/OpenYPlaylistForm.php @@ -6,7 +6,7 @@ use Drupal\Core\Ajax\AjaxResponse; use Drupal\Core\Ajax\HtmlCommand; use Drupal\Core\Entity\ContentEntityForm; -use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\Entity\EntityRepositoryInterface; use Drupal\Core\Entity\EntityTypeBundleInfoInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Render\RendererInterface; @@ -22,10 +22,17 @@ class OpenYPlaylistForm extends ContentEntityForm { /** * OpenYPlaylistForm constructor. * + * @param \Drupal\Core\Entity\EntityRepositoryInterface $entity_repository + * The entity repository. + * @param \Drupal\Core\Entity\EntityTypeBundleInfoInterface $entity_type_bundle_info + * The entity type bundle info. + * @param \Drupal\Component\Datetime\TimeInterface $time + * The time service. * @param \Drupal\Core\Render\RendererInterface $renderer + * The renderer service. */ - public function __construct(EntityManagerInterface $entity_manager, EntityTypeBundleInfoInterface $entity_type_bundle_info = NULL, TimeInterface $time = NULL, RendererInterface $renderer) { - parent::__construct($entity_manager, $entity_type_bundle_info, $time); + public function __construct(EntityRepositoryInterface $entity_repository, EntityTypeBundleInfoInterface $entity_type_bundle_info, TimeInterface $time, RendererInterface $renderer) { + parent::__construct($entity_repository, $entity_type_bundle_info, $time); $this->renderer = $renderer; } @@ -35,7 +42,7 @@ public function __construct(EntityManagerInterface $entity_manager, EntityTypeBu */ public static function create(ContainerInterface $container) { return new static( - $container->get('entity.manager'), + $container->get('entity.repository'), $container->get('entity_type.bundle.info'), $container->get('datetime.time'), $container->get('renderer') diff --git a/modules/openy_digital_signage_playlist/src/Plugin/Block/OpenYDigitalSignageBlockPlaylist.php b/modules/openy_digital_signage_playlist/src/Plugin/Block/OpenYDigitalSignageBlockPlaylist.php index ae0550f..11b6097 100644 --- a/modules/openy_digital_signage_playlist/src/Plugin/Block/OpenYDigitalSignageBlockPlaylist.php +++ b/modules/openy_digital_signage_playlist/src/Plugin/Block/OpenYDigitalSignageBlockPlaylist.php @@ -68,17 +68,17 @@ class OpenYDigitalSignageBlockPlaylist extends BlockBase implements ContainerFac * The plugin definition. * @param \Symfony\Component\DependencyInjection\ContainerInterface $container * The container. - * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_manager + * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager * The entity manager service. * @param \Drupal\openy_digital_signage_screen\OpenYScreenManagerInterface $screen_manager * The Open Y DS Screen Manager. * @param \Drupal\openy_digital_signage_room\OpenYRoomManagerInterface $room_manager * The Open Y DS Room Manager. */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, ContainerInterface $container, EntityTypeManagerInterface $entity_manager, OpenYScreenManagerInterface $screen_manager, OpenYRoomManagerInterface $room_manager) { + public function __construct(array $configuration, $plugin_id, $plugin_definition, ContainerInterface $container, EntityTypeManagerInterface $entity_type_manager, OpenYScreenManagerInterface $screen_manager, OpenYRoomManagerInterface $room_manager) { // Call parent construct method. parent::__construct($configuration, $plugin_id, $plugin_definition); - $this->entityTypeManager = $entity_manager; + $this->entityTypeManager = $entity_type_manager; $this->screenManager = $screen_manager; $this->roomManager = $room_manager; $this->container = $container; @@ -93,7 +93,7 @@ public static function create(ContainerInterface $container, array $configuratio $plugin_id, $plugin_definition, $container, - $container->get('entity.manager'), + $container->get('entity_type.manager'), $container->get('openy_digital_signage_screen.manager'), $container->get('openy_digital_signage_room.manager') ); diff --git a/modules/openy_digital_signage_room/openy_digital_signage_room.services.yml b/modules/openy_digital_signage_room/openy_digital_signage_room.services.yml index 5364954..bdbbc23 100644 --- a/modules/openy_digital_signage_room/openy_digital_signage_room.services.yml +++ b/modules/openy_digital_signage_room/openy_digital_signage_room.services.yml @@ -1,4 +1,4 @@ services: openy_digital_signage_room.manager: class: Drupal\openy_digital_signage_room\OpenYRoomManager - arguments: ['@entity.manager', '@logger.factory', '@config.factory'] + arguments: ['@entity_type.manager', '@logger.factory', '@config.factory'] diff --git a/modules/openy_digital_signage_schedule/openy_digital_signage_schedule.services.yml b/modules/openy_digital_signage_schedule/openy_digital_signage_schedule.services.yml index 366da73..8083ec8 100644 --- a/modules/openy_digital_signage_schedule/openy_digital_signage_schedule.services.yml +++ b/modules/openy_digital_signage_schedule/openy_digital_signage_schedule.services.yml @@ -1,7 +1,7 @@ services: openy_digital_signage_schedule.manager: class: Drupal\openy_digital_signage_schedule\OpenYScheduleManager - arguments: ['@entity.manager', '@entity.query', '@logger.factory'] + arguments: ['@entity_type.manager', '@logger.factory'] plugin.manager.schedule_item_data_type: class: Drupal\openy_digital_signage_schedule\ScheduleItemDataTypePluginManager parent: default_plugin_manager diff --git a/modules/openy_digital_signage_schedule/src/OpenYScheduleManager.php b/modules/openy_digital_signage_schedule/src/OpenYScheduleManager.php index 48601c7..05530aa 100644 --- a/modules/openy_digital_signage_schedule/src/OpenYScheduleManager.php +++ b/modules/openy_digital_signage_schedule/src/OpenYScheduleManager.php @@ -2,14 +2,10 @@ namespace Drupal\openy_digital_signage_schedule; -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; use Drupal\openy_digital_signage_schedule\Entity\OpenYSchedule; use Drupal\openy_digital_signage_screen\Entity\OpenYScreen; -use Drupal\openy_digital_signage_screen\Entity\OpenYScreenInterface; /** * Class OpenYScheduleManager. @@ -26,39 +22,31 @@ class OpenYScheduleManager implements OpenYScheduleManagerInterface { */ const STORAGE = 'openy_digital_signage_schedule'; - /** - * The query factory. - * - * @var QueryFactory - */ - protected $entityQuery; - /** * The entity type manager. * - * @var EntityTypeManager + * @var \Drupal\Core\Entity\EntityTypeManagerInterface */ protected $entityTypeManager; /** * The entity storage. * - * @var EntityStorageInterface + * @var \Drupal\Core\Entity\EntityStorageInterface */ protected $storage; /** * LoggerChannelFactoryInterface definition. * - * @var LoggerChannelFactoryInterface + * @var \Drupal\Core\Logger\LoggerChannelFactoryInterface */ protected $logger; /** * 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); @@ -79,7 +67,7 @@ public function getUpcomingScreenContents(OpenYSchedule $schedule, $timespan, $n $now = time(); } - $query = $this->entityQuery->get('openy_digital_signage_sch_item'); + $query = $this->entityTypeManager->getStorage('openy_digital_signage_sch_item')->getQuery(); $query->condition('schedule', $schedule->id()); if (!$include_disabled) { $query->condition('status', 1); @@ -171,7 +159,7 @@ public function daysWithOverrides(OpenYSchedule $schedule, $year, $month) { $date_last->sub($day_interval); // Retrieve all override schedule items that fit the given month. - $query = $this->entityQuery->get('openy_digital_signage_sch_item'); + $query = $this->entityTypeManager->getStorage('openy_digital_signage_sch_item')->getQuery(); $query->condition('schedule', $schedule->id()); $query->condition('show_date', 0); $query->condition('date__value', $first_day_of_next_month, '<'); diff --git a/modules/openy_digital_signage_screen/openy_digital_signage_screen.services.yml b/modules/openy_digital_signage_screen/openy_digital_signage_screen.services.yml index 52c5605..69df1a0 100644 --- a/modules/openy_digital_signage_screen/openy_digital_signage_screen.services.yml +++ b/modules/openy_digital_signage_screen/openy_digital_signage_screen.services.yml @@ -1,7 +1,7 @@ services: openy_digital_signage_screen.manager: class: Drupal\openy_digital_signage_screen\OpenYScreenManager - arguments: ['@entity.manager', '@entity.query', '@logger.factory', '@current_route_match', '@request_stack'] + arguments: ['@entity_type.manager', '@logger.factory', '@current_route_match', '@request_stack'] openy_digital_signage_screen: class: '\Drupal\openy_digital_signage_screen\EventSubscriber\ResponseEventSubscriber' tags: diff --git a/modules/openy_digital_signage_screen/src/Form/OpenYScreenAddForm.php b/modules/openy_digital_signage_screen/src/Form/OpenYScreenAddForm.php index 2e2f558..1eac85d 100644 --- a/modules/openy_digital_signage_screen/src/Form/OpenYScreenAddForm.php +++ b/modules/openy_digital_signage_screen/src/Form/OpenYScreenAddForm.php @@ -5,11 +5,11 @@ use Drupal\Core\Ajax\AjaxResponse; use Drupal\Core\Ajax\ReplaceCommand; use Drupal\Core\Entity\ContentEntityForm; +use Drupal\Core\Entity\EntityRepositoryInterface; use Drupal\Core\Entity\EntityTypeBundleInfoInterface; -use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Render\Element; -use Drupal\user\PrivateTempStoreFactory; +use Drupal\Core\TempStore\PrivateTempStoreFactory; use Symfony\Component\DependencyInjection\ContainerInterface; use Drupal\Component\Datetime\TimeInterface; @@ -21,24 +21,26 @@ class OpenYScreenAddForm extends ContentEntityForm { /** - * The private temp store. + * TempStore service. * - * @var \Drupal\user\PrivateTempStore + * @var \Drupal\Core\TempStore\PrivateTempStoreFactory */ protected $store; /** * Constructs a ContentEntityForm object. * - * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager - * The entity manager. + * @param \Drupal\Core\Entity\EntityRepositoryInterface $entity_repository + * The entity repository. + * @param \Drupal\Core\TempStore\PrivateTempStoreFactory $temp_store_factory + * TempStore service. * @param \Drupal\Core\Entity\EntityTypeBundleInfoInterface $entity_type_bundle_info * The entity type bundle service. * @param \Drupal\Component\Datetime\TimeInterface $time * The time service. */ - public function __construct(EntityManagerInterface $entity_manager, PrivateTempStoreFactory $temp_store_factory, EntityTypeBundleInfoInterface $entity_type_bundle_info = NULL, TimeInterface $time = NULL) { - parent::__construct($entity_manager, $entity_type_bundle_info, $time); + public function __construct(EntityRepositoryInterface $entity_repository, PrivateTempStoreFactory $temp_store_factory, EntityTypeBundleInfoInterface $entity_type_bundle_info, TimeInterface $time) { + parent::__construct($entity_repository, $entity_type_bundle_info, $time); $this->store = $temp_store_factory->get('multistep_data'); } @@ -47,7 +49,7 @@ public function __construct(EntityManagerInterface $entity_manager, PrivateTempS */ public static function create(ContainerInterface $container) { return new static( - $container->get('entity.manager'), + $container->get('entity.repository'), $container->get('user.private_tempstore'), $container->get('entity_type.bundle.info'), $container->get('datetime.time') diff --git a/modules/openy_digital_signage_screen/src/OpenYScreenManager.php b/modules/openy_digital_signage_screen/src/OpenYScreenManager.php index 95ca1d9..b72bc3a 100644 --- a/modules/openy_digital_signage_screen/src/OpenYScreenManager.php +++ b/modules/openy_digital_signage_screen/src/OpenYScreenManager.php @@ -2,10 +2,7 @@ namespace Drupal\openy_digital_signage_screen; -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; use Drupal\Core\Routing\RouteMatchInterface; use Symfony\Component\HttpFoundation\RequestStack; @@ -27,31 +24,24 @@ class OpenYScreenManager implements OpenYScreenManagerInterface { */ const STORAGE = 'openy_digital_signage_screen'; - /** - * The query factory. - * - * @var QueryFactory - */ - protected $entityQuery; - /** * The entity type manager. * - * @var EntityTypeManager + * @var \Drupal\Core\Entity\EntityTypeManagerInterface */ protected $entityTypeManager; /** * The entity storage. * - * @var EntityStorageInterface + * @var \Drupal\Core\Entity\EntityStorageInterface */ protected $storage; /** * LoggerChannelFactoryInterface definition. * - * @var LoggerChannelFactoryInterface + * @var \Drupal\Core\Logger\LoggerChannelFactoryInterface */ protected $logger; @@ -72,8 +62,7 @@ class OpenYScreenManager implements OpenYScreenManagerInterface { /** * Constructor. */ - public function __construct(EntityTypeManagerInterface $entity_type_manager, QueryFactory $entity_query, LoggerChannelFactoryInterface $logger_factory, RouteMatchInterface $route_match, RequestStack $request_stack) { - $this->entityQuery = $entity_query; + public function __construct(EntityTypeManagerInterface $entity_type_manager, LoggerChannelFactoryInterface $logger_factory, RouteMatchInterface $route_match, RequestStack $request_stack) { $this->entityTypeManager = $entity_type_manager; $this->logger = $logger_factory->get(self::CHANNEL); $this->storage = $this->entityTypeManager->getStorage(self::STORAGE); @@ -93,11 +82,8 @@ public function getScreenContext() { } // Try to find Screen ID in a URL. $screen = NULL; - $request = \Drupal::request(); if ($request->query->has('screen')) { - $storage = \Drupal::entityTypeManager() - ->getStorage('openy_digital_signage_screen'); - $screen = $storage->load($request->query->get('screen')); + $screen = $this->storage->load($request->query->get('screen')); } return $screen; diff --git a/modules/openy_ds_pef_schedule/openy_ds_pef_schedule.services.yml b/modules/openy_ds_pef_schedule/openy_ds_pef_schedule.services.yml index 89cf9fc..c5753f1 100644 --- a/modules/openy_ds_pef_schedule/openy_ds_pef_schedule.services.yml +++ b/modules/openy_ds_pef_schedule/openy_ds_pef_schedule.services.yml @@ -1,4 +1,4 @@ services: openy_ds_pef_schedule.manager: class: Drupal\openy_ds_pef_schedule\OpenYPEFScheduleManager - arguments: ['@entity.manager', '@entity.query', '@logger.factory', '@database'] + arguments: ['@entity_type.manager', '@logger.factory', '@database'] diff --git a/modules/openy_ds_pef_schedule/src/OpenYPEFScheduleManager.php b/modules/openy_ds_pef_schedule/src/OpenYPEFScheduleManager.php index 8108cdd..12589b7 100644 --- a/modules/openy_ds_pef_schedule/src/OpenYPEFScheduleManager.php +++ b/modules/openy_ds_pef_schedule/src/OpenYPEFScheduleManager.php @@ -3,9 +3,7 @@ namespace Drupal\openy_ds_pef_schedule; use Drupal\Core\Database\Connection; -use Drupal\Core\Entity\EntityTypeManager; use Drupal\Core\Entity\EntityTypeManagerInterface; -use Drupal\Core\Entity\Query\QueryFactory; use Drupal\Core\Logger\LoggerChannelFactoryInterface; use Drupal\node\NodeInterface; @@ -25,24 +23,17 @@ class OpenYPEFScheduleManager implements OpenYPEFScheduleManagerInterface { const NEXT_DAY_ALWAYS = 1; const NEXT_DAY_IF_EMPTY = 2; - /** - * The query factory. - * - * @var QueryFactory - */ - protected $entityQuery; - /** * The entity type manager. * - * @var EntityTypeManager + * @var \Drupal\Core\Entity\EntityTypeManagerInterface */ protected $entityTypeManager; /** * LoggerChannelFactoryInterface definition. * - * @var LoggerChannelFactoryInterface + * @var \Drupal\Core\Logger\LoggerChannelFactoryInterface */ protected $logger; @@ -55,9 +46,15 @@ class OpenYPEFScheduleManager implements OpenYPEFScheduleManagerInterface { /** * Constructor. + * + * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager + * The entity type manager. + * @param \Drupal\Core\Logger\LoggerChannelFactoryInterface $logger_factory + * The logger channel factory. + * @param \Drupal\Core\Database\Connection $database + * Database connection. */ - public function __construct(EntityTypeManagerInterface $entity_type_manager, QueryFactory $entity_query, LoggerChannelFactoryInterface $logger_factory, Connection $database) { - $this->entityQuery = $entity_query; + public function __construct(EntityTypeManagerInterface $entity_type_manager, LoggerChannelFactoryInterface $logger_factory, Connection $database) { $this->entityTypeManager = $entity_type_manager; $this->logger = $logger_factory->get(self::CHANNEL); $this->database = $database;