Skip to content

Commit

Permalink
Drupal 9 compatibility fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey-Orlov authored and andypost committed Jul 30, 2020
1 parent ab2294f commit f0fe2a7
Show file tree
Hide file tree
Showing 17 changed files with 65 additions and 53 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
],
"license": "GPL-2.0+",
"require": {
"drupal/core": "^8.8.4",
"drupal/courier": "^2.0@alpha",
"drupal/dynamic_entity_reference": "^1.0",
"drupal/unlimited_number": "^1.0@beta"
"drupal/unlimited_number": "^2.0"
},
"suggest": {
"drupal/token": " Improves token UI on message template forms.",
Expand Down
3 changes: 1 addition & 2 deletions rng.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ description: 'Provides the ability to create and manage events and registrations
package: RNG
core_version_requirement: ^8.8.4 || ^9.0
dependencies:
- drupal:system (>=8.1)
- courier:courier
- dynamic_entity_reference:dynamic_entity_reference
- unlimited_number:unlimited_number (>=8.x-1.0-beta2)
- unlimited_number:unlimited_number
2 changes: 1 addition & 1 deletion rng.services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ services:
- { name: access_check, applies_to: _event_rule_reset }
access_check.rng.event_registrations_allowed:
class: Drupal\rng\Access\RegistrationAddAccessCheck
arguments: ['@entity.manager']
arguments: ['@entity_type.manager']
tags:
- { name: access_check, applies_to: _registration_add_access }
rng.paramconverter.entity_type_rule_component:
Expand Down
8 changes: 0 additions & 8 deletions rng_courier/rng_courier.info.yml

This file was deleted.

24 changes: 0 additions & 24 deletions rng_courier/rng_courier.module

This file was deleted.

13 changes: 13 additions & 0 deletions src/Entity/EventTypeRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,19 @@
* entity_keys = {
* "id" = "id",
* "label" = "id"
* },
* config_export = {
* "entity_type",
* "bundle",
* "machine_name",
* "trigger",
* "conditions",
* "actions",
* "client",
* "format",
* "pager_settings",
* "api_key_settings",
* "parameters",
* }
* )
*/
Expand Down
6 changes: 6 additions & 0 deletions src/Entity/RegistrantType.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@
* "edit-form" = "/admin/structure/rng/registrant_types/manage/{registrant_type}",
* "admin-form" = "/admin/structure/rng/registrant_types/manage/{registrant_type}",
* "collection" = "/admin/structure/rng/registrant_types"
* },
* config_export = {
* "id",
* "label",
* "description",
* "label_pattern",
* }
* )
*/
Expand Down
5 changes: 5 additions & 0 deletions src/Entity/RegistrationType.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
* "canonical" = "/admin/structure/rng/registration_types/manage/{registration_type}",
* "edit-form" = "/admin/structure/rng/registration_types/manage/{registration_type}",
* "delete-form" = "/admin/structure/rng/registration_types/manage/{registration_type}/delete",
* },
* config_export = {
* "id",
* "label",
* "description",
* }
* )
*/
Expand Down
17 changes: 17 additions & 0 deletions src/Entity/RngEventType.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,23 @@
* "delete-form" = "/admin/structure/rng/event_types/manage/{rng_event_type}/delete",
* "event-access-defaults" = "/admin/structure/rng/event_types/manage/{rng_event_type}/access_defaults",
* "field-mapping" = "/admin/structure/rng/event_types/manage/{rng_event_type}/field_mapping",
* },
* config_export = {
* "id",
* "entity_type",
* "bundle",
* "mirror_operation_to_event_manage",
* "custom_rules",
* "default_registrant",
* "allow_anon_registrants",
* "auto_sync_registrants",
* "auto_attach_users",
* "registrant_email_field",
* "event_start_date_field",
* "event_end_date_field",
* "people_types",
* "default_messages",
* "fields",
* }
* )
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Form/EventTypeForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ public function save(array $form, FormStateInterface $form_state) {

$message = ($status == SAVED_UPDATED) ? '%label event type updated.' : '%label event type added.';
$url = $event_type->toUrl();
$t_args = ['%label' => $event_type->id(), 'link' => Link::fromTextAndUrl(t('Edit'), $url)];
$t_args = ['%label' => $event_type->id(), 'link' => (Link::fromTextAndUrl($this->t('Edit'), $url))->toString()];

$this->messenger()->addMessage($this->t($message, $t_args));
$this->logger('rng')->notice($message, $t_args);
Expand Down
2 changes: 1 addition & 1 deletion src/Form/MessageActionForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function __construct(ActionManager $action_manager, EntityTypeManagerInte
public static function create(ContainerInterface $container) {
return new static(
$container->get('plugin.manager.action'),
$container->get('entity.manager'),
$container->get('entity_type.manager'),
$container->get('rng.event_manager')
);
}
Expand Down
20 changes: 12 additions & 8 deletions src/Form/RegistrationTypeForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,35 @@

use Drupal\Core\Entity\EntityForm;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Entity\Query\QueryFactory;
use Drupal\Core\Link;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
* Form controller for registration types.
*/
class RegistrationTypeForm extends EntityForm {
/**
* @var \Drupal\Core\Entity\Query\QueryFactory
* An instance of the entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityQueryFactory;
protected $entityTypeManager;

/**
* {@inheritdoc}
*/
public function __construct(QueryFactory $query_factory) {
$this->entityQueryFactory = $query_factory;
public function __construct(EntityTypeManagerInterface $entity_type_manager) {
$this->entityTypeManager = $entity_type_manager;
}

/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static($container->get('entity.query'));
return new static(
$container->get('entity_type.manager')
);
}

/**
Expand Down Expand Up @@ -80,7 +84,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
* Callback for `id` form element in RegistrationTypeForm->buildForm.
*/
public function exists($entity_id, array $element, FormStateInterface $form_state) {
$query = $this->entityQueryFactory->get('registration_type');
$query = $this->entityTypeManager->getStorage('registration_type')->getQuery();
return (bool) $query->condition('id', $entity_id)->execute();
}

Expand All @@ -93,7 +97,7 @@ public function save(array $form, FormStateInterface $form_state) {

$message = ($status == SAVED_UPDATED) ? '%label registration type was updated.' : '%label registration type was added.';
$url = $registration_type->toUrl();
$t_args = ['%label' => $registration_type->label(), 'link' => Link::fromTextAndUrl(t('Edit'), $url)];
$t_args = ['%label' => $registration_type->label(), 'link' => (Link::fromTextAndUrl($this->t('Edit'), $url))->toString()];

$this->messenger()->addMessage($this->t($message, $t_args));
$this->logger('rng')->notice($message, $t_args);
Expand Down
4 changes: 2 additions & 2 deletions src/Lists/EventTypeListBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ public function __construct(EntityTypeInterface $entity_type, EntityStorageInter
public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {
return new static(
$entity_type,
$container->get('entity.manager')->getStorage($entity_type->id()),
$container->get('entity.manager'),
$container->get('entity_type.manager')->getStorage($entity_type->id()),
$container->get('entity_type.manager'),
$container->get('current_user')
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Lists/GroupListBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function __construct(EntityTypeInterface $entity_type, EntityStorageInter
public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {
return new static(
$entity_type,
$container->get('entity.manager')->getStorage($entity_type->id()),
$container->get('entity_type.manager')->getStorage($entity_type->id()),
$container->get('rng.event_manager')
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Lists/RegistrationListBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function __construct(EntityTypeInterface $entity_type, EntityStorageInter
public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {
return new static(
$entity_type,
$container->get('entity.manager')->getStorage($entity_type->id()),
$container->get('entity_type.manager')->getStorage($entity_type->id()),
$container->get('rng.event_manager')
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Lists/RuleListBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function __construct(EntityTypeInterface $entity_type, EntityStorageInter
public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {
return new static(
$entity_type,
$container->get('entity.manager')->getStorage($entity_type->id()),
$container->get('entity_type.manager')->getStorage($entity_type->id()),
$container->get('rng.event_manager'),
$container->get('redirect.destination')
);
Expand Down
2 changes: 1 addition & 1 deletion src/Plugin/Derivative/LocalActions.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function __construct(EntityTypeManagerInterface $entity_manager, RoutePro
*/
public static function create(ContainerInterface $container, $base_plugin_id) {
return new static(
$container->get('entity.manager'),
$container->get('entity_type.manager'),
$container->get('router.route_provider'),
$container->get('rng.event_manager')
);
Expand Down

0 comments on commit f0fe2a7

Please sign in to comment.