diff --git a/composer.json b/composer.json index 8844437..4f8fcb6 100644 --- a/composer.json +++ b/composer.json @@ -23,9 +23,10 @@ ], "license": "GPL-2.0+", "require": { - "drupal/core": "^8.8.4", + "drupal/core": "^8.8.4 || ^9", + "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.", diff --git a/rng.info.yml b/rng.info.yml index c37cdb6..0d93f18 100644 --- a/rng.info.yml +++ b/rng.info.yml @@ -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 diff --git a/rng.services.yml b/rng.services.yml index 703cb7f..5034f55 100644 --- a/rng.services.yml +++ b/rng.services.yml @@ -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: diff --git a/src/Entity/EventTypeRule.php b/src/Entity/EventTypeRule.php index dafefa7..c02d108 100644 --- a/src/Entity/EventTypeRule.php +++ b/src/Entity/EventTypeRule.php @@ -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", * } * ) */ diff --git a/src/Entity/RegistrantType.php b/src/Entity/RegistrantType.php index 3137e02..82736ec 100644 --- a/src/Entity/RegistrantType.php +++ b/src/Entity/RegistrantType.php @@ -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", * } * ) */ diff --git a/src/Entity/RegistrationType.php b/src/Entity/RegistrationType.php index 9328e82..331e7e0 100644 --- a/src/Entity/RegistrationType.php +++ b/src/Entity/RegistrationType.php @@ -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", * } * ) */ diff --git a/src/Entity/RngEventType.php b/src/Entity/RngEventType.php index f2f3e52..66dba54 100644 --- a/src/Entity/RngEventType.php +++ b/src/Entity/RngEventType.php @@ -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", * } * ) */ diff --git a/src/EventMeta.php b/src/EventMeta.php index 6453c4b..aa81a38 100644 --- a/src/EventMeta.php +++ b/src/EventMeta.php @@ -33,7 +33,7 @@ class EventMeta implements EventMetaInterface { * * @var \Drupal\Core\Entity\EntityTypeManagerInterface */ - protected $entityManager; + protected $entityTypeManager; /** * @var \Drupal\Core\Entity\EntityTypeBundleInfoInterface @@ -92,7 +92,7 @@ class EventMeta implements EventMetaInterface { /** * Constructs a new EventMeta object. * - * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_manager + * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager * The entity manager. * @param EntityTypeBundleInfoInterface $bundle_info * The bundle info. @@ -113,8 +113,8 @@ class EventMeta implements EventMetaInterface { * @param \Drupal\Core\Entity\EntityInterface $entity * The event entity. */ - public function __construct(EntityTypeManagerInterface $entity_manager, EntityTypeBundleInfoInterface $bundle_info, ConfigFactoryInterface $config_factory, SelectionPluginManagerInterface $selection_plugin_manager, IdentityChannelManagerInterface $identity_channel_manager, RngConfigurationInterface $rng_configuration, EventManagerInterface $event_manager, CourierManagerInterface $courier_manager, ActionManager $action_manager, EntityInterface $entity) { - $this->entityManager = $entity_manager; + public function __construct(EntityTypeManagerInterface $entity_type_manager, EntityTypeBundleInfoInterface $bundle_info, ConfigFactoryInterface $config_factory, SelectionPluginManagerInterface $selection_plugin_manager, IdentityChannelManagerInterface $identity_channel_manager, RngConfigurationInterface $rng_configuration, EventManagerInterface $event_manager, CourierManagerInterface $courier_manager, ActionManager $action_manager, EntityInterface $entity) { + $this->entityTypeManager = $entity_type_manager; $this->bundleInfo = $bundle_info; $this->configFactory = $config_factory; $this->selectionPluginManager = $selection_plugin_manager; @@ -192,7 +192,7 @@ public function getRegistrationTypeIds() { * {@inheritdoc} */ public function getRegistrationTypes() { - return $this->entityManager->getStorage('registration_type')->loadMultiple($this->getRegistrationTypeIds()); + return $this->entityTypeManager->getStorage('registration_type')->loadMultiple($this->getRegistrationTypeIds()); } /** @@ -289,7 +289,7 @@ public function getDefaultGroups() { * {@inheritdoc} */ public function buildQuery($entity_type) { - return $this->entityManager->getStorage($entity_type)->getQuery('AND') + return $this->entityTypeManager->getStorage($entity_type)->getQuery('AND') ->condition('event__target_type', $this->getEvent()->getEntityTypeId(), '=') ->condition('event__target_id', $this->getEvent()->id(), '='); } @@ -320,7 +320,7 @@ public function buildRegistrationQuery() { */ public function getRegistrations() { $query = $this->buildRegistrationQuery(); - return $this->entityManager->getStorage('registration')->loadMultiple($query->execute()); + return $this->entityTypeManager->getStorage('registration')->loadMultiple($query->execute()); } /** @@ -358,7 +358,7 @@ public function getRules($trigger = NULL, $defaults = FALSE, $is_active = TRUE) $query->condition('status', $is_active, '='); } - $rules = $this->entityManager + $rules = $this->entityTypeManager ->getStorage('rng_rule') ->loadMultiple($query->execute()); if ($defaults && !$rules) { @@ -380,7 +380,7 @@ public function getDefaultRules($trigger = NULL) { /** @var \Drupal\rng\Entity\EventTypeRuleInterface[] $default_rules */ $default_rules = $this - ->entityManager + ->entityTypeManager ->getStorage('rng_event_type_rule') ->loadByProperties([ 'entity_type' => $this->getEvent()->getEntityTypeId(), @@ -452,14 +452,14 @@ public function buildGroupQuery() { */ public function getGroups() { $query = $this->buildGroupQuery(); - return $this->entityManager->getStorage('registration_group')->loadMultiple($query->execute()); + return $this->entityTypeManager->getStorage('registration_group')->loadMultiple($query->execute()); } /** * {@inheritdoc} */ public function buildRegistrantQuery($entity_type_id = NULL) { - $query = $this->entityManager->getStorage('registrant')->getQuery('AND') + $query = $this->entityTypeManager->getStorage('registrant')->getQuery('AND') ->condition('registration.entity.event__target_type', $this->getEvent()->getEntityTypeId(), '=') ->condition('registration.entity.event__target_id', $this->getEvent()->id(), '='); @@ -475,7 +475,7 @@ public function buildRegistrantQuery($entity_type_id = NULL) { */ public function getRegistrants($entity_type_id = NULL) { $query = $this->buildRegistrantQuery($entity_type_id); - return $this->entityManager->getStorage('registrant')->loadMultiple($query->execute()); + return $this->entityTypeManager->getStorage('registrant')->loadMultiple($query->execute()); } /** @@ -485,7 +485,7 @@ public function canRegisterProxyIdentities() { // Create is checked first since it is usually the cheapest. $identity_types = $this->getCreatableIdentityTypes(); foreach ($identity_types as $entity_type_id => $bundles) { - $accessControl = $this->entityManager->getAccessControlHandler($entity_type_id); + $accessControl = $this->entityTypeManager->getAccessControlHandler($entity_type_id); if ($this->entityTypeHasBundles($entity_type_id)) { foreach ($bundles as $bundle) { if ($accessControl->createAccess($bundle)) { @@ -654,7 +654,7 @@ public function addDefaultAccess() { * Whether an entity type uses a separate bundle entity type. */ protected function entityTypeHasBundles($entity_type_id) { - $entity_type = $this->entityManager->getDefinition($entity_type_id); + $entity_type = $this->entityTypeManager->getDefinition($entity_type_id); return ($entity_type->getBundleEntityType() !== NULL); } diff --git a/src/EventSubscriber/RngRequestSubscriber.php b/src/EventSubscriber/RngRequestSubscriber.php index 625edd0..1a5944f 100644 --- a/src/EventSubscriber/RngRequestSubscriber.php +++ b/src/EventSubscriber/RngRequestSubscriber.php @@ -3,7 +3,7 @@ namespace Drupal\rng\EventSubscriber; use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Symfony\Component\HttpKernel\Event\PostResponseEvent; +use Symfony\Component\HttpKernel\Event\TerminateEvent; use Symfony\Component\HttpKernel\KernelEvents; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\rng\RngEntityModelInterface; @@ -54,10 +54,10 @@ public function __construct(EntityTypeManagerInterface $entity_type_manager, Rng /** * Run RNG rules for entity operations which occurred during this request. * - * @param \Symfony\Component\HttpKernel\Event\PostResponseEvent $event + * @param \Symfony\Component\HttpKernel\Event\TerminateEvent $event * The event to process. */ - public function onKernelTerminate(PostResponseEvent $event) { + public function onKernelTerminate(TerminateEvent $event) { $operation_records = $this->rngEntityModel->getOperationRecords(); foreach ($operation_records as $operation_record) { if ($operation_record->getEntityTypeId() == 'registration') { diff --git a/src/Form/EventTypeForm.php b/src/Form/EventTypeForm.php index face22c..7de85ec 100644 --- a/src/Form/EventTypeForm.php +++ b/src/Form/EventTypeForm.php @@ -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); diff --git a/src/Form/MessageActionForm.php b/src/Form/MessageActionForm.php index 86ba5ca..16795bb 100644 --- a/src/Form/MessageActionForm.php +++ b/src/Form/MessageActionForm.php @@ -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') ); } diff --git a/src/Form/RegistrationTypeForm.php b/src/Form/RegistrationTypeForm.php index 0e7e3a2..a8860fd 100644 --- a/src/Form/RegistrationTypeForm.php +++ b/src/Form/RegistrationTypeForm.php @@ -4,8 +4,8 @@ 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; /** @@ -13,22 +13,26 @@ */ 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') + ); } /** @@ -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(); } diff --git a/src/Lists/EventTypeListBuilder.php b/src/Lists/EventTypeListBuilder.php index 44e8d68..d6d6120 100644 --- a/src/Lists/EventTypeListBuilder.php +++ b/src/Lists/EventTypeListBuilder.php @@ -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') ); } diff --git a/src/Lists/GroupListBuilder.php b/src/Lists/GroupListBuilder.php index 2fd9973..1af866f 100644 --- a/src/Lists/GroupListBuilder.php +++ b/src/Lists/GroupListBuilder.php @@ -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') ); } diff --git a/src/Lists/RegistrationListBuilder.php b/src/Lists/RegistrationListBuilder.php index c49d37f..9637cfc 100644 --- a/src/Lists/RegistrationListBuilder.php +++ b/src/Lists/RegistrationListBuilder.php @@ -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') ); } diff --git a/src/Lists/RuleListBuilder.php b/src/Lists/RuleListBuilder.php index 63a2d07..a986ade 100644 --- a/src/Lists/RuleListBuilder.php +++ b/src/Lists/RuleListBuilder.php @@ -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') ); diff --git a/src/Plugin/Derivative/LocalActions.php b/src/Plugin/Derivative/LocalActions.php index 3962151..de799ef 100644 --- a/src/Plugin/Derivative/LocalActions.php +++ b/src/Plugin/Derivative/LocalActions.php @@ -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') );