function LayoutBuilderEntityViewDisplay::getContextsForEntity
Same name in other branches
- 8.9.x core/modules/layout_builder/src/Entity/LayoutBuilderEntityViewDisplay.php \Drupal\layout_builder\Entity\LayoutBuilderEntityViewDisplay::getContextsForEntity()
- 10 core/modules/layout_builder/src/Entity/LayoutBuilderEntityViewDisplay.php \Drupal\layout_builder\Entity\LayoutBuilderEntityViewDisplay::getContextsForEntity()
- 11.x 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 335
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);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.