LayoutSectionStorageParamConverter.php in Drupal 10
File
core/modules/layout_builder/src/Routing/LayoutSectionStorageParamConverter.php
View source
<?php
namespace Drupal\layout_builder\Routing;
use Drupal\Core\ParamConverter\ParamConverterInterface;
use Drupal\layout_builder\SectionStorage\SectionStorageManagerInterface;
use Symfony\Component\Routing\Route;
class LayoutSectionStorageParamConverter implements ParamConverterInterface {
protected $sectionStorageManager;
public function __construct(SectionStorageManagerInterface $section_storage_manager) {
$this->sectionStorageManager = $section_storage_manager;
}
public function convert($value, $definition, $name, array $defaults) {
if (!isset($defaults['section_storage_type']) || !$this->sectionStorageManager
->hasDefinition($defaults['section_storage_type'])) {
return NULL;
}
$type = $defaults['section_storage_type'];
$contexts = $this->sectionStorageManager
->loadEmpty($type)
->deriveContextsFromRoute($value, $definition, $name, $defaults);
return $this->sectionStorageManager
->load($type, $contexts);
}
public function applies($definition, $name, Route $route) {
return !empty($definition['layout_builder_section_storage']) || !empty($definition['layout_builder_tempstore']);
}
}