class RouteSubscriber in Layout Builder Restrictions 8.2
Same name in this branch
- 8.2 src/Routing/RouteSubscriber.php \Drupal\layout_builder_restrictions\Routing\RouteSubscriber
- 8.2 modules/layout_builder_restrictions_by_region/src/Routing/RouteSubscriber.php \Drupal\layout_builder_restrictions_by_region\Routing\RouteSubscriber
Override the controller for layout_builder.move_block.
Hierarchy
- class \Drupal\Core\Routing\RouteSubscriberBase implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
- class \Drupal\layout_builder_restrictions\Routing\RouteSubscriber
Expanded class hierarchy of RouteSubscriber
1 string reference to 'RouteSubscriber'
1 service uses RouteSubscriber
File
- src/
Routing/ RouteSubscriber.php, line 11
Namespace
Drupal\layout_builder_restrictions\RoutingView source
class RouteSubscriber extends RouteSubscriberBase {
/**
* {@inheritdoc}
*/
public function alterRoutes(RouteCollection $collection) {
if ($route = $collection
->get('layout_builder.move_block')) {
$defaults = $route
->getDefaults();
$defaults['_controller'] = '\\Drupal\\layout_builder_restrictions\\Controller\\MoveBlockController::build';
$route
->setDefaults($defaults);
}
if ($route = $collection
->get('layout_builder.move_block_form')) {
// Provide validation to the Layout Builder MoveBlock form.
$route
->setDefault('_form', '\\Drupal\\layout_builder_restrictions\\Form\\MoveBlockForm');
}
// Add inline block filtering to parent class
// Drupal\layout_builder\Controller\ChooseBlockController.
if ($route = $collection
->get('layout_builder.choose_block')) {
$defaults = $route
->getDefaults();
$defaults['_controller'] = '\\Drupal\\layout_builder_restrictions\\Controller\\ChooseBlockController::build';
$route
->setDefaults($defaults);
}
if ($route = $collection
->get('layout_builder.choose_inline_block')) {
$defaults = $route
->getDefaults();
$defaults['_controller'] = '\\Drupal\\layout_builder_restrictions\\Controller\\ChooseBlockController::inlineBlockList';
$route
->setDefaults($defaults);
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
RouteSubscriber:: |
public | function |
Alters existing routes for a specific collection. Overrides RouteSubscriberBase:: |
|
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 |