LayoutTempstoreRouteEnhancer.php in Drupal 10
File
core/modules/layout_builder/src/Routing/LayoutTempstoreRouteEnhancer.php
View source
<?php
namespace Drupal\layout_builder\Routing;
use Drupal\Core\Routing\EnhancerInterface;
use Drupal\Core\Routing\RouteObjectInterface;
use Drupal\layout_builder\LayoutTempstoreRepositoryInterface;
use Drupal\layout_builder\SectionStorageInterface;
use Symfony\Component\HttpFoundation\Request;
class LayoutTempstoreRouteEnhancer implements EnhancerInterface {
protected $layoutTempstoreRepository;
public function __construct(LayoutTempstoreRepositoryInterface $layout_tempstore_repository) {
$this->layoutTempstoreRepository = $layout_tempstore_repository;
}
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;
}
}