Skip to content
This repository has been archived by the owner on Feb 23, 2020. It is now read-only.

168 - Renamed the default routing parameter #169

Open
wants to merge 1 commit into
base: 8.x-1.x
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
2 changes: 1 addition & 1 deletion src/Access/EntityIsEventCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion src/Access/EventRuleResetCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion src/Access/RegistrationAddAccessCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/ContextProvider/RngEventRouteContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
16 changes: 8 additions & 8 deletions src/Controller/RegistrationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
]);
}
Expand Down Expand Up @@ -104,16 +104,16 @@ 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
* The type of registration.
*
* @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(),
]);
Expand Down
2 changes: 1 addition & 1 deletion src/Plugin/Menu/LocalAction/ResetAccessRules.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')) {
Expand Down
4 changes: 2 additions & 2 deletions src/Routing/Enhancer/RngRouteEnhancer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
18 changes: 9 additions & 9 deletions src/Routing/RouteSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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',
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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',
Expand All @@ -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',
Expand Down