function NavigationSectionStorage::buildRoutes

Same name and namespace in other branches
  1. 11.x core/modules/navigation/src/Plugin/SectionStorage/NavigationSectionStorage.php \Drupal\navigation\Plugin\SectionStorage\NavigationSectionStorage::buildRoutes()

Provides the routes needed for Layout Builder UI.

Allows the plugin to add or alter routes during the route building process. \Drupal\layout_builder\Routing\LayoutBuilderRoutesTrait is provided for the typical use case of building a standard Layout Builder UI.

Parameters

\Symfony\Component\Routing\RouteCollection $collection: The route collection.

Overrides SectionStorageInterface::buildRoutes

File

core/modules/navigation/src/Plugin/SectionStorage/NavigationSectionStorage.php, line 147

Class

NavigationSectionStorage
Provides navigation section storage.

Namespace

Drupal\navigation\Plugin\SectionStorage

Code

public function buildRoutes(RouteCollection $collection) : void {
    $this->buildLayoutRoutes($collection, $this->getPluginDefinition(), '/admin/config/user-interface/navigation-block');
    $default_route = 'layout_builder.' . $this->getPluginDefinition()
        ->id() . '.view';
    $route = $collection->get($default_route);
    // Use a form for editing the layout instead of a controller.
    $defaults = $route->getDefaults();
    $defaults['_form'] = LayoutForm::class;
    unset($defaults['_controller']);
    $route->setDefaults($defaults);
}

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