public function LayoutSectionStorageParamConverter::convert in Drupal 10
Converts path variables to their corresponding objects.
Parameters
mixed $value: The raw value.
mixed $definition: The parameter definition provided in the route options.
string $name: The name of the parameter.
array $defaults: The route defaults array.
Return value
mixed|null The converted parameter value.
Overrides ParamConverterInterface::convert
File
- core/
modules/ layout_builder/ src/ Routing/ LayoutSectionStorageParamConverter.php, line 37
Class
- LayoutSectionStorageParamConverter
- Loads the section storage from the routing defaults.
Namespace
Drupal\layout_builder\RoutingCode
public function convert($value, $definition, $name, array $defaults) {
// If no section storage type is specified or if it is invalid, return.
if (!isset($defaults['section_storage_type']) || !$this->sectionStorageManager
->hasDefinition($defaults['section_storage_type'])) {
return NULL;
}
$type = $defaults['section_storage_type'];
// Load an empty instance and derive the available contexts.
$contexts = $this->sectionStorageManager
->loadEmpty($type)
->deriveContextsFromRoute($value, $definition, $name, $defaults);
// Attempt to load a full instance based on the context.
return $this->sectionStorageManager
->load($type, $contexts);
}