Mercurial > hg > isophonics-drupal-site
annotate core/modules/layout_builder/src/Routing/LayoutBuilderRoutes.php @ 14:1fec387a4317
Update Drupal core to 8.5.2 via Composer
author | Chris Cannam |
---|---|
date | Mon, 23 Apr 2018 09:46:53 +0100 |
parents | |
children | af1871eacc83 |
rev | line source |
---|---|
Chris@14 | 1 <?php |
Chris@14 | 2 |
Chris@14 | 3 namespace Drupal\layout_builder\Routing; |
Chris@14 | 4 |
Chris@14 | 5 use Drupal\Core\Routing\RouteBuildEvent; |
Chris@14 | 6 use Drupal\Core\Routing\RoutingEvents; |
Chris@14 | 7 use Drupal\layout_builder\SectionStorage\SectionStorageManagerInterface; |
Chris@14 | 8 use Symfony\Component\EventDispatcher\EventSubscriberInterface; |
Chris@14 | 9 |
Chris@14 | 10 /** |
Chris@14 | 11 * Provides routes for the Layout Builder UI. |
Chris@14 | 12 * |
Chris@14 | 13 * @internal |
Chris@14 | 14 */ |
Chris@14 | 15 class LayoutBuilderRoutes implements EventSubscriberInterface { |
Chris@14 | 16 |
Chris@14 | 17 /** |
Chris@14 | 18 * The section storage manager. |
Chris@14 | 19 * |
Chris@14 | 20 * @var \Drupal\layout_builder\SectionStorage\SectionStorageManagerInterface |
Chris@14 | 21 */ |
Chris@14 | 22 protected $sectionStorageManager; |
Chris@14 | 23 |
Chris@14 | 24 /** |
Chris@14 | 25 * Constructs a new LayoutBuilderRoutes. |
Chris@14 | 26 * |
Chris@14 | 27 * @param \Drupal\layout_builder\SectionStorage\SectionStorageManagerInterface $section_storage_manager |
Chris@14 | 28 * The section storage manager. |
Chris@14 | 29 */ |
Chris@14 | 30 public function __construct(SectionStorageManagerInterface $section_storage_manager) { |
Chris@14 | 31 $this->sectionStorageManager = $section_storage_manager; |
Chris@14 | 32 } |
Chris@14 | 33 |
Chris@14 | 34 /** |
Chris@14 | 35 * Alters existing routes for a specific collection. |
Chris@14 | 36 * |
Chris@14 | 37 * @param \Drupal\Core\Routing\RouteBuildEvent $event |
Chris@14 | 38 * The route build event. |
Chris@14 | 39 */ |
Chris@14 | 40 public function onAlterRoutes(RouteBuildEvent $event) { |
Chris@14 | 41 $collection = $event->getRouteCollection(); |
Chris@14 | 42 foreach ($this->sectionStorageManager->getDefinitions() as $plugin_id => $definition) { |
Chris@14 | 43 $this->sectionStorageManager->loadEmpty($plugin_id)->buildRoutes($collection); |
Chris@14 | 44 } |
Chris@14 | 45 } |
Chris@14 | 46 |
Chris@14 | 47 /** |
Chris@14 | 48 * {@inheritdoc} |
Chris@14 | 49 */ |
Chris@14 | 50 public static function getSubscribedEvents() { |
Chris@14 | 51 // Run after \Drupal\field_ui\Routing\RouteSubscriber. |
Chris@14 | 52 $events[RoutingEvents::ALTER] = ['onAlterRoutes', -110]; |
Chris@14 | 53 return $events; |
Chris@14 | 54 } |
Chris@14 | 55 |
Chris@14 | 56 } |