You are here

public function PageManagerSectionStorage::deriveContextsFromRoute in Page Manager 8.4

Derives the available plugin contexts from route values.

This should only be called during section storage instantiation, specifically for use by the routing system. For all non-routing usages, use \Drupal\Component\Plugin\ContextAwarePluginInterface::getContextValue().

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

\Drupal\Core\Plugin\Context\ContextInterface[] The available plugin contexts.

Overrides SectionStorageInterface::deriveContextsFromRoute

See also

\Drupal\Core\ParamConverter\ParamConverterInterface::convert()

File

src/Plugin/SectionStorage/PageManagerSectionStorage.php, line 163

Class

PageManagerSectionStorage
Defines the 'page_manager' section storage type.

Namespace

Drupal\page_manager\Plugin\SectionStorage

Code

public function deriveContextsFromRoute($value, $definition, $name, array $defaults) {

  // Try to load from defaults.
  $entity = $this
    ->extractEntityFromRoute($value, $defaults);

  // Otherwise try the tempstore.
  if (!$entity) {
    $entity = $this->tempstore
      ->get('page_manager.layout_builder')
      ->get($value);
  }
  return [
    'entity' => EntityContext::fromEntity($entity),
  ];
}