You are here

protected function RouteSubscriber::alterRoutes in Layout Builder Symmetric Translations 8

Alters existing routes for a specific collection.

Parameters

\Symfony\Component\Routing\RouteCollection $collection: The route collection for adding routes.

Overrides RouteSubscriberBase::alterRoutes

File

src/Routing/RouteSubscriber.php, line 17

Class

RouteSubscriber
Listens to the dynamic route events.

Namespace

Drupal\layout_builder_st\Routing

Code

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');
    }
  }
}