You are here

protected function LayoutBuilderEntityViewDisplay::getContextsForEntity in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/layout_builder/src/Entity/LayoutBuilderEntityViewDisplay.php \Drupal\layout_builder\Entity\LayoutBuilderEntityViewDisplay::getContextsForEntity()

Gets the available contexts for a given entity.

Parameters

\Drupal\Core\Entity\FieldableEntityInterface $entity: The entity.

Return value

\Drupal\Core\Plugin\Context\ContextInterface[] An array of context objects for a given entity.

2 calls to LayoutBuilderEntityViewDisplay::getContextsForEntity()
LayoutBuilderEntityViewDisplay::buildSections in core/modules/layout_builder/src/Entity/LayoutBuilderEntityViewDisplay.php
Builds the render array for the sections of a given entity.
LayoutBuilderEntityViewDisplay::getRuntimeSections in core/modules/layout_builder/src/Entity/LayoutBuilderEntityViewDisplay.php
Gets the runtime sections for a given entity.

File

core/modules/layout_builder/src/Entity/LayoutBuilderEntityViewDisplay.php, line 336

Class

LayoutBuilderEntityViewDisplay
Provides an entity view display entity that has a layout.

Namespace

Drupal\layout_builder\Entity

Code

protected function getContextsForEntity(FieldableEntityInterface $entity) {
  return [
    'view_mode' => new Context(ContextDefinition::create('string'), $this
      ->getMode()),
    'entity' => EntityContext::fromEntity($entity),
    'display' => EntityContext::fromEntity($this),
  ] + $this
    ->contextRepository()
    ->getAvailableContexts();
}