function LayoutBuilderRoutes::onAlterRoutes

Same name in other branches
  1. 9 core/modules/layout_builder/src/Routing/LayoutBuilderRoutes.php \Drupal\layout_builder\Routing\LayoutBuilderRoutes::onAlterRoutes()
  2. 8.9.x core/modules/layout_builder/src/Routing/LayoutBuilderRoutes.php \Drupal\layout_builder\Routing\LayoutBuilderRoutes::onAlterRoutes()
  3. 11.x core/modules/layout_builder/src/Routing/LayoutBuilderRoutes.php \Drupal\layout_builder\Routing\LayoutBuilderRoutes::onAlterRoutes()

Alters existing routes for a specific collection.

Parameters

\Drupal\Core\Routing\RouteBuildEvent $event: The route build event.

File

core/modules/layout_builder/src/Routing/LayoutBuilderRoutes.php, line 41

Class

LayoutBuilderRoutes
Provides routes for the Layout Builder UI.

Namespace

Drupal\layout_builder\Routing

Code

public function onAlterRoutes(RouteBuildEvent $event) {
    $collection = $event->getRouteCollection();
    foreach ($this->sectionStorageManager
        ->getDefinitions() as $plugin_id => $definition) {
        $this->sectionStorageManager
            ->loadEmpty($plugin_id)
            ->buildRoutes($collection);
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.