public function SettingsContextHandler::getContexts in Core Context 8
Returns all contexts attached to an entity.
Parameters
\Drupal\Core\Entity\EntityInterface $entity:
Return value
\Drupal\Component\Plugin\Context\ContextInterface[]
Overrides EntityContextHandlerInterface::getContexts
File
- src/
SettingsContextHandler.php, line 47
Class
- SettingsContextHandler
- Exposes contexts stored in an entity's third-party settings.
Namespace
Drupal\core_contextCode
public function getContexts(EntityInterface $entity) {
assert($entity instanceof ThirdPartySettingsInterface);
$contexts = $entity
->getThirdPartySetting('core_context', 'contexts', []);
$contexts = $this->contextMapper
->getContextValues($contexts);
return $this
->applyCaching($contexts, $entity);
}