protected function RouteSubscriber::alterRoutes in Token 8
Alters existing routes for a specific collection.
Parameters
\Symfony\Component\Routing\RouteCollection $collection: The route collection for adding routes.
Overrides RouteSubscriberBase::alterRoutes
File
- src/
Routing/ RouteSubscriber.php, line 35
Class
- RouteSubscriber
- Subscriber for Devel routes.
Namespace
Drupal\token\RoutingCode
protected function alterRoutes(RouteCollection $collection) {
foreach ($this->entityTypeManager
->getDefinitions() as $entity_type_id => $entity_type) {
if ($devel_render = $entity_type
->getLinkTemplate('token-devel')) {
$options = [
'_admin_route' => TRUE,
'_token_entity_type_id' => $entity_type_id,
'parameters' => [
$entity_type_id => [
'type' => 'entity:' . $entity_type_id,
],
],
];
$route = new Route($devel_render, [
'_controller' => '\\Drupal\\token\\Controller\\TokenDevelController::entityTokens',
'_title' => 'Devel Tokens',
], [
'_permission' => 'access devel information',
'_module_dependencies' => 'devel',
], $options);
$collection
->add("entity.{$entity_type_id}.token_devel", $route);
}
}
}