function OverridesSectionStorage::buildRoutes

Same name and namespace in other branches
  1. 9 core/modules/layout_builder/src/Plugin/SectionStorage/OverridesSectionStorage.php \Drupal\layout_builder\Plugin\SectionStorage\OverridesSectionStorage::buildRoutes()
  2. 10 core/modules/layout_builder/src/Plugin/SectionStorage/OverridesSectionStorage.php \Drupal\layout_builder\Plugin\SectionStorage\OverridesSectionStorage::buildRoutes()
  3. 11.x core/modules/layout_builder/src/Plugin/SectionStorage/OverridesSectionStorage.php \Drupal\layout_builder\Plugin\SectionStorage\OverridesSectionStorage::buildRoutes()

Overrides SectionStorageInterface::buildRoutes

File

core/modules/layout_builder/src/Plugin/SectionStorage/OverridesSectionStorage.php, line 252

Class

OverridesSectionStorage
Defines the 'overrides' section storage type.

Namespace

Drupal\layout_builder\Plugin\SectionStorage

Code

public function buildRoutes(RouteCollection $collection) {
    foreach ($this->getEntityTypes() as $entity_type_id => $entity_type) {
        // If the canonical route does not exist, do not provide any Layout
        // Builder UI routes for this entity type.
        if (!$collection->get("entity.{$entity_type_id}.canonical")) {
            continue;
        }
        $defaults = [];
        $defaults['entity_type_id'] = $entity_type_id;
        // Retrieve the requirements from the canonical route.
        $requirements = $collection->get("entity.{$entity_type_id}.canonical")
            ->getRequirements();
        $options = [];
        // Ensure that upcasting is run in the correct order.
        $options['parameters']['section_storage'] = [];
        $options['parameters'][$entity_type_id]['type'] = 'entity:' . $entity_type_id;
        $template = $entity_type->getLinkTemplate('canonical') . '/layout';
        $this->buildLayoutRoutes($collection, $this->getPluginDefinition(), $template, $defaults, $requirements, $options, $entity_type_id, $entity_type_id);
    }
}

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