protected function ContextProviderBase::getContextsFromEntity in Core Context 8
Extracts contexts from an entity.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The entity from which to extract contexts.
Return value
\Drupal\Component\Plugin\Context\ContextInterface[] The contexts extracted from the entity.
2 calls to ContextProviderBase::getContextsFromEntity()
- CanonicalEntity::getContextsFromRoute in src/
ContextProvider/ CanonicalEntity.php - Extracts contexts from the current route.
- LayoutBuilder::getContextsFromRoute in src/
ContextProvider/ LayoutBuilder.php - Extracts contexts from the current route.
File
- src/
ContextProvider/ ContextProviderBase.php, line 40
Class
- ContextProviderBase
- Provides a base class for context providers.
Namespace
Drupal\core_context\ContextProviderCode
protected function getContextsFromEntity(EntityInterface $entity) {
$entity_type = $entity
->getEntityType();
if ($entity_type
->hasHandlerClass('context')) {
return $this->entityTypeManager
->getHandler($entity_type
->id(), 'context')
->getContexts($entity);
}
return [];
}