final class RouteSubscriber in Layout Builder Symmetric Translations 8
Listens to the dynamic route events.
Hierarchy
- class \Drupal\Core\Routing\RouteSubscriberBase implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
- class \Drupal\layout_builder_st\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_st\RoutingView source
final class RouteSubscriber extends RouteSubscriberBase {
/**
* {@inheritdoc}
*/
protected function alterRoutes(RouteCollection $collection) {
foreach ($collection
->all() as $route) {
// Add the _layout_builder_translation_access requirement to all routes
// that have the _layout_builder_access requirement.
if ($route
->getRequirement('_layout_builder_access') === 'view' && !$route
->hasRequirement('_layout_builder_translation_access')) {
$route
->setRequirement('_layout_builder_translation_access', 'untranslated');
}
}
}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
// Come before \Drupal\layout_builder\Routing\LayoutBuilderRoutes. So that
// only routes provide by layout_builder.routes.yml are altered.
$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 |