class RouteSubscriber in RNG - Events and Registrations 8.2
Same name in this branch
- 8.2 src/Routing/RouteSubscriber.php \Drupal\rng\Routing\RouteSubscriber
- 8.2 rng_debug/src/Routing/RouteSubscriber.php \Drupal\rng_debug\Routing\RouteSubscriber
Same name and namespace in other branches
- 8 rng_debug/src/Routing/RouteSubscriber.php \Drupal\rng_debug\Routing\RouteSubscriber
- 3.x rng_debug/src/Routing/RouteSubscriber.php \Drupal\rng_debug\Routing\RouteSubscriber
Dynamic routes.
Hierarchy
- class \Drupal\Core\Routing\RouteSubscriberBase implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
- class \Drupal\rng_debug\Routing\RouteSubscriber
Expanded class hierarchy of RouteSubscriber
1 string reference to 'RouteSubscriber'
- rng_debug.services.yml in rng_debug/
rng_debug.services.yml - rng_debug/rng_debug.services.yml
1 service uses RouteSubscriber
File
- rng_debug/
src/ Routing/ RouteSubscriber.php, line 14
Namespace
Drupal\rng_debug\RoutingView source
class RouteSubscriber extends RouteSubscriberBase {
/**
* The entity type manager.
*
* @var \Drupal\Core\Entity\EntityManagerInterface
*/
protected $entityManager;
/**
* The RNG event manager.
*
* @var \Drupal\rng\EventManagerInterface
*/
protected $eventManager;
/**
* Constructs a RouteSubscriber object.
*
* @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
* The entity manager.
* @param \Drupal\rng\EventManagerInterface $event_manager
* The RNG event manager.
*/
public function __construct(EntityManagerInterface $entity_manager, EventManagerInterface $event_manager) {
$this->entityManager = $entity_manager;
$this->eventManager = $event_manager;
}
/**
* {@inheritdoc}
*/
protected function alterRoutes(RouteCollection $collection) {
$event_types = $this->eventManager
->getEventTypes();
foreach (array_keys($event_types) as $entity_type) {
$definition = $this->entityManager
->getDefinition($entity_type);
if ($canonical_path = $definition
->getLinkTemplate('canonical')) {
$manage_requirements = [
'_entity_access' => $entity_type . '.manage event',
'_entity_is_event' => 'TRUE',
'_permission' => 'debug rng',
];
$options = [];
$options['parameters'][$entity_type]['type'] = 'entity:' . $entity_type;
// Rules.
$route = new Route($canonical_path . '/event/rules', [
'_controller' => '\\Drupal\\rng_debug\\Controller\\DebugController::listing',
'_title' => 'Rules',
'event' => $entity_type,
], $manage_requirements, $options);
$collection
->add("rng.event.{$entity_type}.rules", $route);
}
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
RouteSubscriber:: |
protected | property | The entity type manager. | |
RouteSubscriber:: |
protected | property | The RNG event manager. | |
RouteSubscriber:: |
protected | function |
Alters existing routes for a specific collection. Overrides RouteSubscriberBase:: |
|
RouteSubscriber:: |
public | function | Constructs a RouteSubscriber object. | |
RouteSubscriberBase:: |
public static | function | Returns an array of event names this subscriber wants to listen to. | 5 |
RouteSubscriberBase:: |
public | function | Delegates the route altering to self::alterRoutes(). | 1 |