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 9, 2021
1 parent 692f453 commit c040d3c
Show file tree
Hide file tree
Showing 14 changed files with 71 additions and 109 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"
}
}
}
]
}
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 @@ -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 @@ -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;
Expand All @@ -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
Expand All @@ -36,16 +36,16 @@ 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;
}

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'),
Expand Down Expand Up @@ -123,21 +123,21 @@ 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.
if ($time_slot->show_date == 0 && $show_date == 0) {
$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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
Expand All @@ -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')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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')
);
Expand Down
Original file line number Diff line number Diff line change
@@ -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']
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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, '<');
Expand Down
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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');
}

Expand All @@ -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')
Expand Down
Loading

0 comments on commit c040d3c

Please sign in to comment.