You are here

public function DefaultsSectionStorage::deriveContextsFromRoute in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/layout_builder/src/Plugin/SectionStorage/DefaultsSectionStorage.php \Drupal\layout_builder\Plugin\SectionStorage\DefaultsSectionStorage::deriveContextsFromRoute()
  2. 10 core/modules/layout_builder/src/Plugin/SectionStorage/DefaultsSectionStorage.php \Drupal\layout_builder\Plugin\SectionStorage\DefaultsSectionStorage::deriveContextsFromRoute()

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

core/modules/layout_builder/src/Plugin/SectionStorage/DefaultsSectionStorage.php, line 276

Class

DefaultsSectionStorage
Defines the 'defaults' section storage type.

Namespace

Drupal\layout_builder\Plugin\SectionStorage

Code

public function deriveContextsFromRoute($value, $definition, $name, array $defaults) {
  $contexts = [];
  if ($entity = $this
    ->extractEntityFromRoute($value, $defaults)) {
    $contexts['display'] = EntityContext::fromEntity($entity);
  }
  return $contexts;
}