Loading recurring_events.routing.yml +9 −0 Changes for recurring_events.routing.yml: 9 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ entity.eventseries.add_form: requirements: _entity_create_access: 'eventseries' options: _recurring_events_operation_route: TRUE parameters: eventseries_type: type: entity:eventseries_type Loading @@ -33,6 +34,8 @@ entity.eventseries.add_page: _controller: '\Drupal\recurring_events\Controller\EventSeriesController::addPage' requirements: _entity_create_access: 'eventseries' options: _recurring_events_operation_route: TRUE # Edit an EventSeries. entity.eventseries.edit_form: Loading @@ -44,6 +47,7 @@ entity.eventseries.edit_form: _entity_access: 'eventseries.edit' eventseries: \d+ options: _recurring_events_operation_route: TRUE parameters: eventseries: type: entity:eventseries Loading @@ -58,6 +62,7 @@ entity.eventseries.delete_form: _entity_access: 'eventseries.delete' eventseries: \d+ options: _recurring_events_operation_route: TRUE parameters: eventseries: type: entity:eventseries Loading @@ -72,6 +77,7 @@ entity.eventseries.clone_form: _entity_access: 'eventseries.clone' eventseries: \d+ options: _recurring_events_operation_route: TRUE parameters: eventseries: type: entity:eventseries Loading Loading @@ -111,6 +117,7 @@ entity.eventinstance.edit_form: _entity_access: 'eventinstance.edit' eventinstance: \d+ options: _recurring_events_operation_route: TRUE parameters: eventinstance: type: entity:eventinstance Loading @@ -125,6 +132,7 @@ entity.eventinstance.delete_form: _entity_access: 'eventinstance.delete' eventinstance: \d+ options: _recurring_events_operation_route: TRUE parameters: eventinstance: type: entity:eventinstance Loading @@ -139,6 +147,7 @@ entity.eventinstance.clone_form: requirements: _entity_access: 'eventinstance.clone' options: _recurring_events_operation_route: TRUE parameters: eventinstance: type: entity:eventinstance Loading recurring_events.services.yml +5 −0 Changes for recurring_events.services.yml: 5 added lines, 0 removed lines. Original line number Diff line number Diff line services: recurring_events.admin_path.route_subscriber: class: Drupal\recurring_events\EventSubscriber\RecurringEventsAdminRouteSubscriber arguments: ['@config.factory', '@router.builder'] tags: - { name: event_subscriber } recurring_events.event_creation_service: class: Drupal\recurring_events\EventCreationService arguments: ['@string_translation', '@database', '@logger.factory', '@messenger', '@plugin.manager.field.field_type', '@entity_field.manager', '@module_handler', '@entity_type.manager', '@keyvalue'] src/EventSubscriber/RecurringEventsAdminRouteSubscriber.php 0 → 100644 +78 −0 Changes for src/EventSubscriber/RecurringEventsAdminRouteSubscriber.php: 78 added lines, 0 removed lines. Original line number Diff line number Diff line <?php namespace Drupal\recurring_events\EventSubscriber; use Drupal\Core\Config\ConfigCrudEvent; use Drupal\Core\Config\ConfigEvents; use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Routing\RouteBuilderInterface; use Drupal\Core\Routing\RouteSubscriberBase; use Symfony\Component\Routing\RouteCollection; /** * Sets the _admin_route for specific recurring events related routes. */ class RecurringEventsAdminRouteSubscriber extends RouteSubscriberBase { /** * The config factory. * * @var \Drupal\Core\Config\ConfigFactoryInterface */ protected $configFactory; /** * The router builder. * * @var \Drupal\Core\Routing\RouteBuilderInterface */ protected $routerBuilder; /** * Constructs a new RecurringEventsAdminRouteSubscriber. * * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory * The config factory. * @param \Drupal\Core\Routing\RouteBuilderInterface $router_builder * The router builder service. */ public function __construct(ConfigFactoryInterface $config_factory, RouteBuilderInterface $router_builder) { $this->configFactory = $config_factory; $this->routerBuilder = $router_builder; } /** * {@inheritdoc} */ protected function alterRoutes(RouteCollection $collection) { var_dump('yes'); if ($this->configFactory->get('node.settings')->get('use_admin_theme')) { foreach ($collection->all() as $route) { if ($route->hasOption('_recurring_events_operation_route')) { $route->setOption('_admin_route', TRUE); } } } } /** * Rebuilds the router when node.settings:use_admin_theme is changed. * * @param \Drupal\Core\Config\ConfigCrudEvent $event */ public function onConfigSave(ConfigCrudEvent $event) { if ($event->getConfig()->getName() === 'node.settings' && $event->isChanged('use_admin_theme')) { $this->routerBuilder->setRebuildNeeded(); } } /** * {@inheritdoc} */ public static function getSubscribedEvents() { $events = parent::getSubscribedEvents(); $events[ConfigEvents::SAVE][] = ['onConfigSave', 0]; return $events; } } Loading
recurring_events.routing.yml +9 −0 Changes for recurring_events.routing.yml: 9 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ entity.eventseries.add_form: requirements: _entity_create_access: 'eventseries' options: _recurring_events_operation_route: TRUE parameters: eventseries_type: type: entity:eventseries_type Loading @@ -33,6 +34,8 @@ entity.eventseries.add_page: _controller: '\Drupal\recurring_events\Controller\EventSeriesController::addPage' requirements: _entity_create_access: 'eventseries' options: _recurring_events_operation_route: TRUE # Edit an EventSeries. entity.eventseries.edit_form: Loading @@ -44,6 +47,7 @@ entity.eventseries.edit_form: _entity_access: 'eventseries.edit' eventseries: \d+ options: _recurring_events_operation_route: TRUE parameters: eventseries: type: entity:eventseries Loading @@ -58,6 +62,7 @@ entity.eventseries.delete_form: _entity_access: 'eventseries.delete' eventseries: \d+ options: _recurring_events_operation_route: TRUE parameters: eventseries: type: entity:eventseries Loading @@ -72,6 +77,7 @@ entity.eventseries.clone_form: _entity_access: 'eventseries.clone' eventseries: \d+ options: _recurring_events_operation_route: TRUE parameters: eventseries: type: entity:eventseries Loading Loading @@ -111,6 +117,7 @@ entity.eventinstance.edit_form: _entity_access: 'eventinstance.edit' eventinstance: \d+ options: _recurring_events_operation_route: TRUE parameters: eventinstance: type: entity:eventinstance Loading @@ -125,6 +132,7 @@ entity.eventinstance.delete_form: _entity_access: 'eventinstance.delete' eventinstance: \d+ options: _recurring_events_operation_route: TRUE parameters: eventinstance: type: entity:eventinstance Loading @@ -139,6 +147,7 @@ entity.eventinstance.clone_form: requirements: _entity_access: 'eventinstance.clone' options: _recurring_events_operation_route: TRUE parameters: eventinstance: type: entity:eventinstance Loading
recurring_events.services.yml +5 −0 Changes for recurring_events.services.yml: 5 added lines, 0 removed lines. Original line number Diff line number Diff line services: recurring_events.admin_path.route_subscriber: class: Drupal\recurring_events\EventSubscriber\RecurringEventsAdminRouteSubscriber arguments: ['@config.factory', '@router.builder'] tags: - { name: event_subscriber } recurring_events.event_creation_service: class: Drupal\recurring_events\EventCreationService arguments: ['@string_translation', '@database', '@logger.factory', '@messenger', '@plugin.manager.field.field_type', '@entity_field.manager', '@module_handler', '@entity_type.manager', '@keyvalue']
src/EventSubscriber/RecurringEventsAdminRouteSubscriber.php 0 → 100644 +78 −0 Changes for src/EventSubscriber/RecurringEventsAdminRouteSubscriber.php: 78 added lines, 0 removed lines. Original line number Diff line number Diff line <?php namespace Drupal\recurring_events\EventSubscriber; use Drupal\Core\Config\ConfigCrudEvent; use Drupal\Core\Config\ConfigEvents; use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Routing\RouteBuilderInterface; use Drupal\Core\Routing\RouteSubscriberBase; use Symfony\Component\Routing\RouteCollection; /** * Sets the _admin_route for specific recurring events related routes. */ class RecurringEventsAdminRouteSubscriber extends RouteSubscriberBase { /** * The config factory. * * @var \Drupal\Core\Config\ConfigFactoryInterface */ protected $configFactory; /** * The router builder. * * @var \Drupal\Core\Routing\RouteBuilderInterface */ protected $routerBuilder; /** * Constructs a new RecurringEventsAdminRouteSubscriber. * * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory * The config factory. * @param \Drupal\Core\Routing\RouteBuilderInterface $router_builder * The router builder service. */ public function __construct(ConfigFactoryInterface $config_factory, RouteBuilderInterface $router_builder) { $this->configFactory = $config_factory; $this->routerBuilder = $router_builder; } /** * {@inheritdoc} */ protected function alterRoutes(RouteCollection $collection) { var_dump('yes'); if ($this->configFactory->get('node.settings')->get('use_admin_theme')) { foreach ($collection->all() as $route) { if ($route->hasOption('_recurring_events_operation_route')) { $route->setOption('_admin_route', TRUE); } } } } /** * Rebuilds the router when node.settings:use_admin_theme is changed. * * @param \Drupal\Core\Config\ConfigCrudEvent $event */ public function onConfigSave(ConfigCrudEvent $event) { if ($event->getConfig()->getName() === 'node.settings' && $event->isChanged('use_admin_theme')) { $this->routerBuilder->setRebuildNeeded(); } } /** * {@inheritdoc} */ public static function getSubscribedEvents() { $events = parent::getSubscribedEvents(); $events[ConfigEvents::SAVE][] = ['onConfigSave', 0]; return $events; } }