class LayoutBuilderRoutes

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

Provides routes for the Layout Builder UI.

@internal Tagged services are internal.

Hierarchy

  • class \Drupal\layout_builder\Routing\LayoutBuilderRoutes implements \Symfony\Component\EventDispatcher\EventSubscriberInterface

Expanded class hierarchy of LayoutBuilderRoutes

1 file declares its use of LayoutBuilderRoutes
LayoutBuilderRoutesTest.php in core/modules/layout_builder/tests/src/Unit/LayoutBuilderRoutesTest.php
1 string reference to 'LayoutBuilderRoutes'
layout_builder.services.yml in core/modules/layout_builder/layout_builder.services.yml
core/modules/layout_builder/layout_builder.services.yml
1 service uses LayoutBuilderRoutes
layout_builder.routes in core/modules/layout_builder/layout_builder.services.yml
Drupal\layout_builder\Routing\LayoutBuilderRoutes

File

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

Namespace

Drupal\layout_builder\Routing
View source
class LayoutBuilderRoutes implements EventSubscriberInterface {
    
    /**
     * The section storage manager.
     *
     * @var \Drupal\layout_builder\SectionStorage\SectionStorageManagerInterface
     */
    protected $sectionStorageManager;
    
    /**
     * Constructs a new LayoutBuilderRoutes.
     *
     * @param \Drupal\layout_builder\SectionStorage\SectionStorageManagerInterface $section_storage_manager
     *   The section storage manager.
     */
    public function __construct(SectionStorageManagerInterface $section_storage_manager) {
        $this->sectionStorageManager = $section_storage_manager;
    }
    
    /**
     * Alters existing routes for a specific collection.
     *
     * @param \Drupal\Core\Routing\RouteBuildEvent $event
     *   The route build event.
     */
    public function onAlterRoutes(RouteBuildEvent $event) {
        $collection = $event->getRouteCollection();
        foreach ($this->sectionStorageManager
            ->getDefinitions() as $plugin_id => $definition) {
            $this->sectionStorageManager
                ->loadEmpty($plugin_id)
                ->buildRoutes($collection);
        }
    }
    
    /**
     * {@inheritdoc}
     */
    public static function getSubscribedEvents() : array {
        // Run after \Drupal\field_ui\Routing\RouteSubscriber.
        $events[RoutingEvents::ALTER] = [
            'onAlterRoutes',
            -110,
        ];
        return $events;
    }

}

Members

Title Sort descending Modifiers Object type Summary
LayoutBuilderRoutes::$sectionStorageManager protected property The section storage manager.
LayoutBuilderRoutes::getSubscribedEvents public static function
LayoutBuilderRoutes::onAlterRoutes public function Alters existing routes for a specific collection.
LayoutBuilderRoutes::__construct public function Constructs a new LayoutBuilderRoutes.

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