function LayoutTempstoreRouteEnhancer::enhance

Same name in other branches
  1. 9 core/modules/layout_builder/src/Routing/LayoutTempstoreRouteEnhancer.php \Drupal\layout_builder\Routing\LayoutTempstoreRouteEnhancer::enhance()
  2. 11.x core/modules/layout_builder/src/Routing/LayoutTempstoreRouteEnhancer.php \Drupal\layout_builder\Routing\LayoutTempstoreRouteEnhancer::enhance()

Overrides EnhancerInterface::enhance

File

core/modules/layout_builder/src/Routing/LayoutTempstoreRouteEnhancer.php, line 36

Class

LayoutTempstoreRouteEnhancer
Loads the section storage from the layout tempstore.

Namespace

Drupal\layout_builder\Routing

Code

public function enhance(array $defaults, Request $request) {
    $parameters = $defaults[RouteObjectInterface::ROUTE_OBJECT]->getOption('parameters');
    if (isset($parameters['section_storage']['layout_builder_tempstore']) && isset($defaults['section_storage']) && $defaults['section_storage'] instanceof SectionStorageInterface) {
        $defaults['section_storage'] = $this->layoutTempstoreRepository
            ->get($defaults['section_storage']);
    }
    return $defaults;
}

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