You are here

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

Expanded class hierarchy of RouteSubscriber

1 string reference to 'RouteSubscriber'
layout_builder_st.services.yml in ./layout_builder_st.services.yml
layout_builder_st.services.yml
1 service uses RouteSubscriber
layout_builder.route_subscriber in ./layout_builder_st.services.yml
Drupal\layout_builder_st\Routing\RouteSubscriber

File

src/Routing/RouteSubscriber.php, line 12

Namespace

Drupal\layout_builder_st\Routing
View 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

Namesort descending Modifiers Type Description Overrides
RouteSubscriber::alterRoutes protected function Alters existing routes for a specific collection. Overrides RouteSubscriberBase::alterRoutes
RouteSubscriber::getSubscribedEvents public static function Returns an array of event names this subscriber wants to listen to. Overrides RouteSubscriberBase::getSubscribedEvents
RouteSubscriberBase::onAlterRoutes public function Delegates the route altering to self::alterRoutes(). 1