protected function LayoutBuilderEntityViewDisplay::getContextsForEntity in Drupal 9
Same name and namespace in other branches
- 8 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.
1 call 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.
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\EntityCode
protected function getContextsForEntity(FieldableEntityInterface $entity) {
$available_context_ids = array_keys($this
->contextRepository()
->getAvailableContexts());
return [
'view_mode' => new Context(ContextDefinition::create('string'), $this
->getMode()),
'entity' => EntityContext::fromEntity($entity),
'display' => EntityContext::fromEntity($this),
] + $this
->contextRepository()
->getRuntimeContexts($available_context_ids);
}