class RouteSubscriber in Layout Builder Browser 8
Listens to the dynamic route events.
Hierarchy
- class \Drupal\Core\Routing\RouteSubscriberBase implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
- class \Drupal\layout_builder_browser\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_browser\RoutingView source
class RouteSubscriber extends RouteSubscriberBase {
/**
* {@inheritdoc}
*/
protected function alterRoutes(RouteCollection $collection) {
// Override the layout builder choose block controller with ours.
if ($route = $collection
->get('layout_builder.choose_block')) {
$route
->setDefault('_controller', '\\Drupal\\layout_builder_browser\\Controller\\BrowserController::browse');
}
}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
// Ensure we alter the controller after other modules, see
// https://www.drupal.org/node/3129158.
$events[RoutingEvents::ALTER] = [
'onAlterRoutes',
-110,
];
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 |