protected function RouteSubscriber::alterRoutes in Display Suite 8.4
Same name in this branch
- 8.4 src/Routing/RouteSubscriber.php \Drupal\ds\Routing\RouteSubscriber::alterRoutes()
- 8.4 modules/ds_devel/src/Routing/RouteSubscriber.php \Drupal\ds_devel\Routing\RouteSubscriber::alterRoutes()
- 8.4 modules/ds_extras/src/EventSubscriber/RouteSubscriber.php \Drupal\ds_extras\EventSubscriber\RouteSubscriber::alterRoutes()
Same name and namespace in other branches
- 8.2 src/Routing/RouteSubscriber.php \Drupal\ds\Routing\RouteSubscriber::alterRoutes()
- 8.3 src/Routing/RouteSubscriber.php \Drupal\ds\Routing\RouteSubscriber::alterRoutes()
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 36
Class
- RouteSubscriber
- Subscriber for Devel routes.
Namespace
Drupal\ds\RoutingCode
protected function alterRoutes(RouteCollection $collection) {
foreach ($this->entityTypeManager
->getDefinitions() as $entity_type_id => $entity_type) {
$base_table = $entity_type
->getBaseTable();
if ($entity_type
->get('field_ui_base_route') && !empty($base_table)) {
if ($display = $entity_type
->getLinkTemplate('display')) {
$route = new Route($display, [
'_controller' => '\\Drupal\\ds\\Controller\\DsController::contextualTab',
'_title' => 'Manage display',
'entity_type_id' => $entity_type_id,
], [
'_field_ui_view_mode_access' => 'administer ' . $entity_type_id . ' display',
], [
'_admin_route' => TRUE,
'_ds_entity_type_id' => $entity_type_id,
'parameters' => [
$entity_type_id => [
'type' => 'entity:' . $entity_type_id,
],
],
]);
$collection
->add("entity.{$entity_type_id}.display", $route);
}
}
}
}