From 83b439f32a710e1d3874b9a758f1de96f34ad3f6 Mon Sep 17 00:00:00 2001 From: Owen Bush Date: Thu, 7 Jun 2018 10:09:33 -0600 Subject: [PATCH] 168 - Renamed the default routing parameter "event" to "rng_event"type" to prevent possible clashes with custom entity routes which use "event" as a routing parameter. --- src/Access/EntityIsEventCheck.php | 2 +- src/Access/EventRuleResetCheck.php | 2 +- src/Access/RegistrationAddAccessCheck.php | 2 +- src/ContextProvider/RngEventRouteContext.php | 2 +- src/Controller/RegistrationController.php | 16 ++++++++-------- .../Menu/LocalAction/ResetAccessRules.php | 2 +- src/Routing/Enhancer/RngRouteEnhancer.php | 4 ++-- src/Routing/RouteSubscriber.php | 18 +++++++++--------- 8 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/Access/EntityIsEventCheck.php b/src/Access/EntityIsEventCheck.php index 7537332..1a5c91c 100644 --- a/src/Access/EntityIsEventCheck.php +++ b/src/Access/EntityIsEventCheck.php @@ -36,7 +36,7 @@ public function __construct(EventManagerInterface $event_manager) { * Checks that an entity is an event type. */ public function access(Route $route, RouteMatchInterface $route_match, AccountInterface $account) { - if ($event = $route->getDefault('event')) { + if ($event = $route->getDefault('rng_event_type')) { $event = $route_match->getParameter($event); if ($event instanceof EntityInterface) { $event_type = $this->eventManager->eventType($event->getEntityTypeId(), $event->bundle()); diff --git a/src/Access/EventRuleResetCheck.php b/src/Access/EventRuleResetCheck.php index bffc299..065d50b 100644 --- a/src/Access/EventRuleResetCheck.php +++ b/src/Access/EventRuleResetCheck.php @@ -38,7 +38,7 @@ public function __construct(EventManagerInterface $event_manager) { public function access(Route $route, RouteMatchInterface $route_match, AccountInterface $account) { $access = AccessResult::neutral(); - if ($event = $route->getDefault('event')) { + if ($event = $route->getDefault('rng_event_type')) { $event = $route_match->getParameter($event); if ($event instanceof EntityInterface) { $event_type = $this->eventManager->eventType($event->getEntityTypeId(), $event->bundle()); diff --git a/src/Access/RegistrationAddAccessCheck.php b/src/Access/RegistrationAddAccessCheck.php index ccba74c..17b61d3 100644 --- a/src/Access/RegistrationAddAccessCheck.php +++ b/src/Access/RegistrationAddAccessCheck.php @@ -36,7 +36,7 @@ public function __construct(EntityManagerInterface $entity_manager) { * Checks new registrations are permitted on an event. */ public function access(Route $route, RouteMatchInterface $route_match, AccountInterface $account, RegistrationTypeInterface $registration_type = NULL) { - if ($event = $route->getDefault('event')) { + if ($event = $route->getDefault('rng_event_type')) { $context = ['event' => $route_match->getParameter($event)]; $access_control_handler = $this->entityManager->getAccessControlHandler('registration'); if ($registration_type) { diff --git a/src/ContextProvider/RngEventRouteContext.php b/src/ContextProvider/RngEventRouteContext.php index 019ee77..d605cb6 100644 --- a/src/ContextProvider/RngEventRouteContext.php +++ b/src/ContextProvider/RngEventRouteContext.php @@ -80,7 +80,7 @@ protected function getEventInRoute() { return NULL; } - if ($event_param = $route->getDefault('event')) { + if ($event_param = $route->getDefault('rng_event_type')) { $event = $this->routeMatch->getParameter($event_param); return $event instanceof EntityInterface ? $event : NULL; } diff --git a/src/Controller/RegistrationController.php b/src/Controller/RegistrationController.php index f4fe9fa..3fc87b2 100644 --- a/src/Controller/RegistrationController.php +++ b/src/Controller/RegistrationController.php @@ -48,19 +48,19 @@ public static function create(ContainerInterface $container) { * @param \Drupal\Core\Routing\RouteMatchInterface $route_match * The matched route. * - * @param string $event + * @param string $rng_event_type * The parameter to find the event entity. * * @return array A registration form. */ - public function RegistrationAddPage(RouteMatchInterface $route_match, $event) { - $event_entity = $route_match->getParameter($event); + public function RegistrationAddPage(RouteMatchInterface $route_match, $rng_event_type) { + $event_entity = $route_match->getParameter($rng_event_type); $render = []; $registration_types = $this->eventManager->getMeta($event_entity)->getRegistrationTypes(); if (count($registration_types) == 1) { $registration_type = array_shift($registration_types); - return $this->redirect('rng.event.' . $event . '.register', [ - $event => $event_entity->id(), + return $this->redirect('rng.event.' . $rng_event_type . '.register', [ + $rng_event_type => $event_entity->id(), 'registration_type' => $registration_type->id(), ]); } @@ -104,7 +104,7 @@ public function RegistrationAddPage(RouteMatchInterface $route_match, $event) { * @param \Drupal\Core\Routing\RouteMatchInterface $route_match * The matched route. * - * @param string $event + * @param string $rng_event_type * The parameter to find the event entity. * * @param \Drupal\rng\RegistrationTypeInterface $registration_type @@ -112,8 +112,8 @@ public function RegistrationAddPage(RouteMatchInterface $route_match, $event) { * * @return array A registration form. */ - public function RegistrationAdd(RouteMatchInterface $route_match, $event, RegistrationTypeInterface $registration_type) { - $event_entity = $route_match->getParameter($event); + public function RegistrationAdd(RouteMatchInterface $route_match, $rng_event_type, RegistrationTypeInterface $registration_type) { + $event_entity = $route_match->getParameter($rng_event_type); $registration = Registration::create([ 'type' => $registration_type->id(), ]); diff --git a/src/Plugin/Menu/LocalAction/ResetAccessRules.php b/src/Plugin/Menu/LocalAction/ResetAccessRules.php index 4a67235..d06da30 100644 --- a/src/Plugin/Menu/LocalAction/ResetAccessRules.php +++ b/src/Plugin/Menu/LocalAction/ResetAccessRules.php @@ -72,7 +72,7 @@ public static function create(ContainerInterface $container, array $configuratio */ public function getTitle() { $route = $this->routeProvider->getRouteByName($this->getRouteName()); - $param = $route->getDefault('event'); + $param = $route->getDefault('rng_event_type'); if ($event = $this->currentRoute->getParameter($param)) { if ($this->eventManager->getMeta($event)->isDefaultRules('rng_event.register')) { diff --git a/src/Routing/Enhancer/RngRouteEnhancer.php b/src/Routing/Enhancer/RngRouteEnhancer.php index b508eec..40126e0 100644 --- a/src/Routing/Enhancer/RngRouteEnhancer.php +++ b/src/Routing/Enhancer/RngRouteEnhancer.php @@ -15,14 +15,14 @@ class RngRouteEnhancer implements RouteEnhancerInterface { * {@inheritdoc} */ public function applies(Route $route) { - return $route->hasRequirement('_entity_is_event') && $route->hasDefault('event'); + return $route->hasRequirement('_entity_is_event') && $route->hasDefault('rng_event_type'); } /** * {@inheritdoc} */ public function enhance(array $defaults, Request $request) { - $event_entity_type = $defaults['event']; + $event_entity_type = $defaults['rng_event_type']; if (isset($defaults[$event_entity_type])) { $rng_event = $defaults[$event_entity_type]; diff --git a/src/Routing/RouteSubscriber.php b/src/Routing/RouteSubscriber.php index df96bb4..51ba267 100644 --- a/src/Routing/RouteSubscriber.php +++ b/src/Routing/RouteSubscriber.php @@ -69,7 +69,7 @@ protected function alterRoutes(RouteCollection $collection) { '_form' => '\Drupal\rng\Form\EventSettingsForm', '_title' => 'Manage event', // Tell controller which parameter the event entity is stored. - 'event' => $entity_type, + 'rng_event_type' => $entity_type, ), $manage_requirements, $options @@ -82,7 +82,7 @@ protected function alterRoutes(RouteCollection $collection) { [ '_form' => '\Drupal\rng\Form\EventAccessForm', '_title' => 'Access', - 'event' => $entity_type, + 'rng_event_type' => $entity_type, ], $manage_requirements, $options @@ -95,7 +95,7 @@ protected function alterRoutes(RouteCollection $collection) { array( '_form' => '\Drupal\rng\Form\EventAccessResetForm', '_title' => 'Reset access to default', - 'event' => $entity_type, + 'rng_event_type' => $entity_type, ), $manage_requirements + [ '_event_rule_reset' => 'TRUE', @@ -110,7 +110,7 @@ protected function alterRoutes(RouteCollection $collection) { array( '_form' => '\Drupal\rng\Form\MessageListForm', '_title' => 'Messages', - 'event' => $entity_type, + 'rng_event_type' => $entity_type, ), $manage_requirements, $options @@ -123,7 +123,7 @@ protected function alterRoutes(RouteCollection $collection) { array( '_form' => '\Drupal\rng\Form\MessageActionForm', '_title' => 'Add message', - 'event' => $entity_type, + 'rng_event_type' => $entity_type, ), $manage_requirements, $options @@ -136,7 +136,7 @@ protected function alterRoutes(RouteCollection $collection) { array( '_controller' => '\Drupal\rng\Controller\GroupController::listing', '_title' => 'Groups', - 'event' => $entity_type, + 'rng_event_type' => $entity_type, ), $manage_requirements, $options @@ -149,7 +149,7 @@ protected function alterRoutes(RouteCollection $collection) { array( '_controller' => '\Drupal\rng\Controller\GroupController::GroupAdd', '_title' => 'Add group', - 'event' => $entity_type, + 'rng_event_type' => $entity_type, ), $manage_requirements, $options @@ -162,7 +162,7 @@ protected function alterRoutes(RouteCollection $collection) { array( '_controller' => '\Drupal\rng\Controller\RegistrationController::RegistrationAddPage', '_title' => 'Register', - 'event' => $entity_type, + 'rng_event_type' => $entity_type, ), array( '_registration_add_access' => 'TRUE', @@ -178,7 +178,7 @@ protected function alterRoutes(RouteCollection $collection) { array( '_controller' => '\Drupal\rng\Controller\RegistrationController::RegistrationAdd', '_title_callback' => '\Drupal\rng\Controller\RegistrationController::addPageTitle', - 'event' => $entity_type, + 'rng_event_type' => $entity_type, ), array( '_registration_add_access' => 'TRUE',