public function LayoutTempstoreRouteEnhancer::enhance in Drupal 10
Updates the defaults for a route definition based on the request.
Parameters
array $defaults: The defaults, maps to '_defaults' in the route definition YAML.
\Symfony\Component\HttpFoundation\Request $request: The Request instance.
Return value
array The modified defaults. Each enhancer MUST return the $defaults but may add or remove values.
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\RoutingCode
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;
}