class RouteSubscriber in Layout Builder Lock 8
Add additional requirements for Layout builder routes.
Hierarchy
- class \Drupal\Core\Routing\RouteSubscriberBase implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
- class \Drupal\layout_builder_lock\Routing\RouteSubscriber
Expanded class hierarchy of RouteSubscriber
1 string reference to 'RouteSubscriber'
1 service uses RouteSubscriber
File
- src/
Routing/ RouteSubscriber.php, line 12
Namespace
Drupal\layout_builder_lock\RoutingView source
class RouteSubscriber extends RouteSubscriberBase {
/**
* {@inheritdoc}
*/
protected function alterRoutes(RouteCollection $collection) {
$routes = [
'layout_builder.move_block' => 'block_reorder',
'layout_builder.move_block_form' => 'block_reorder',
'layout_builder.choose_block' => 'block_add',
'layout_builder.choose_inline_block' => 'block_add',
'layout_builder.update_block' => 'block_config',
'layout_builder.remove_block' => 'block_remove',
'layout_builder.choose_section' => 'section_add',
'layout_builder.configure_section' => 'section_edit',
'layout_builder.remove_section' => 'section_remove',
];
foreach ($routes as $route_name => $access) {
if ($route = $collection
->get($route_name)) {
$route
->setRequirement('_layout_builder_lock_access', $access);
}
}
}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
$events[RoutingEvents::ALTER] = [
'onAlterRoutes',
-100,
];
return $events;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
RouteSubscriber:: |
protected | function |
Alters existing routes for a specific collection. Overrides RouteSubscriberBase:: |
|
RouteSubscriber:: |
public static | function |
Returns an array of event names this subscriber wants to listen to. Overrides RouteSubscriberBase:: |
|
RouteSubscriberBase:: |
public | function | Delegates the route altering to self::alterRoutes(). | 1 |