LayoutBuilderRoutes.php in Drupal 8
File
core/modules/layout_builder/src/Routing/LayoutBuilderRoutes.php
View source
<?php
namespace Drupal\layout_builder\Routing;
use Drupal\Core\Routing\RouteBuildEvent;
use Drupal\Core\Routing\RoutingEvents;
use Drupal\layout_builder\SectionStorage\SectionStorageManagerInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class LayoutBuilderRoutes implements EventSubscriberInterface {
protected $sectionStorageManager;
public function __construct(SectionStorageManagerInterface $section_storage_manager) {
$this->sectionStorageManager = $section_storage_manager;
}
public function onAlterRoutes(RouteBuildEvent $event) {
$collection = $event
->getRouteCollection();
foreach ($this->sectionStorageManager
->getDefinitions() as $plugin_id => $definition) {
$this->sectionStorageManager
->loadEmpty($plugin_id)
->buildRoutes($collection);
}
}
public static function getSubscribedEvents() {
$events[RoutingEvents::ALTER] = [
'onAlterRoutes',
-110,
];
return $events;
}
}