protected function RouteSubscriber::alterRoutes in Layout Builder Restrictions 8.2
Same name in this branch
- 8.2 src/Routing/RouteSubscriber.php \Drupal\layout_builder_restrictions\Routing\RouteSubscriber::alterRoutes()
- 8.2 modules/layout_builder_restrictions_by_region/src/Routing/RouteSubscriber.php \Drupal\layout_builder_restrictions_by_region\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
- modules/
layout_builder_restrictions_by_region/ src/ Routing/ RouteSubscriber.php, line 37
Class
- RouteSubscriber
- Subscriber for Layout Builder Restrictions By Region routes.
Namespace
Drupal\layout_builder_restrictions_by_region\RoutingCode
protected function alterRoutes(RouteCollection $collection) {
foreach ($this->entityTypeManager
->getDefinitions() as $entity_type_id => $entity_type) {
if ($route_name = $entity_type
->get('field_ui_base_route')) {
// Try to get the route from the current collection.
if (!$collection
->get($route_name)) {
continue;
}
$route = new Route("/admin/layout-builder-restrictions/layout-builder-restrictions-by-region/{$entity_type_id}/allowed-blocks-form", [
'_form' => '\\Drupal\\layout_builder_restrictions_by_region\\Form\\AllowedBlocksForm',
'_title' => 'Allowed Blocks',
], [
'_permission' => 'administer ' . $entity_type_id . ' display',
]);
$collection
->add("layout_builder_restrictions_by_region.{$entity_type_id}_allowed_blocks", $route);
}
}
}