You are here

class LayoutBuilderRoutes in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/layout_builder/src/Routing/LayoutBuilderRoutes.php \Drupal\layout_builder\Routing\LayoutBuilderRoutes
  2. 9 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

Namesort descending Modifiers Type Description Overrides
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.