Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some extra changes for D9. #3

Open
wants to merge 3 commits into
base: d9
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
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
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
28 changes: 14 additions & 14 deletions src/EventMeta.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class EventMeta implements EventMetaInterface {
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityManager;
protected $entityTypeManager;

/**
* @var \Drupal\Core\Entity\EntityTypeBundleInfoInterface
Expand Down Expand Up @@ -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.
Expand All @@ -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;
Expand Down Expand Up @@ -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());
}

/**
Expand Down Expand Up @@ -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(), '=');
}
Expand Down Expand Up @@ -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());
}

/**
Expand Down Expand Up @@ -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) {
Expand All @@ -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(),
Expand Down Expand Up @@ -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(), '=');

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

/**
Expand All @@ -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)) {
Expand Down Expand Up @@ -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);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Entity manager addressed in d9-fixes branch where I did split commits on per d-org issue

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically rename of the variable is useless at the moment

return ($entity_type->getBundleEntityType() !== NULL);
}

Expand Down
6 changes: 3 additions & 3 deletions src/EventSubscriber/RngRequestSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please file separate issue for that, also it needs link to change record where the event was renamed

$operation_records = $this->rngEntityModel->getOperationRecords();
foreach ($operation_records as $operation_record) {
if ($operation_record->getEntityTypeId() == 'registration') {
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()];

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, also it needs separate issue (probably it exists)

Moreover it needs to rework messages as they are not translatable yet

Copy link

@andypost andypost Jul 30, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


$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
18 changes: 11 additions & 7 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 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