function LayoutBuilderEntityViewDisplay::getContextsForEntity
Same name in other branches
- 9 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.
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\EntityCode
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();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.