class LayoutTempstoreRouteEnhancer

Same name in other branches
  1. 10 core/modules/layout_builder/src/Routing/LayoutTempstoreRouteEnhancer.php \Drupal\layout_builder\Routing\LayoutTempstoreRouteEnhancer
  2. 11.x core/modules/layout_builder/src/Routing/LayoutTempstoreRouteEnhancer.php \Drupal\layout_builder\Routing\LayoutTempstoreRouteEnhancer

Loads the section storage from the layout tempstore.

Hierarchy

Expanded class hierarchy of LayoutTempstoreRouteEnhancer

1 file declares its use of LayoutTempstoreRouteEnhancer
LayoutTempstoreRouteEnhancerTest.php in core/modules/layout_builder/tests/src/Unit/LayoutTempstoreRouteEnhancerTest.php
1 string reference to 'LayoutTempstoreRouteEnhancer'
layout_builder.services.yml in core/modules/layout_builder/layout_builder.services.yml
core/modules/layout_builder/layout_builder.services.yml
1 service uses LayoutTempstoreRouteEnhancer
layout_builder.tempstore.route_enhancer in core/modules/layout_builder/layout_builder.services.yml
Drupal\layout_builder\Routing\LayoutTempstoreRouteEnhancer

File

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

Namespace

Drupal\layout_builder\Routing
View source
class LayoutTempstoreRouteEnhancer implements EnhancerInterface {
    
    /**
     * The layout tempstore repository.
     *
     * @var \Drupal\layout_builder\LayoutTempstoreRepositoryInterface
     */
    protected $layoutTempstoreRepository;
    
    /**
     * Constructs a new LayoutTempstoreRouteEnhancer.
     *
     * @param \Drupal\layout_builder\LayoutTempstoreRepositoryInterface $layout_tempstore_repository
     *   The layout tempstore repository.
     */
    public function __construct(LayoutTempstoreRepositoryInterface $layout_tempstore_repository) {
        $this->layoutTempstoreRepository = $layout_tempstore_repository;
    }
    
    /**
     * {@inheritdoc}
     */
    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;
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title
LayoutTempstoreRouteEnhancer::$layoutTempstoreRepository protected property The layout tempstore repository.
LayoutTempstoreRouteEnhancer::enhance public function Overrides EnhancerInterface::enhance
LayoutTempstoreRouteEnhancer::__construct public function Constructs a new LayoutTempstoreRouteEnhancer.

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