You are here

public function ContextAwarePluginBase::getContexts in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Component/Plugin/ContextAwarePluginBase.php \Drupal\Component\Plugin\ContextAwarePluginBase::getContexts()

Gets the defined contexts.

Return value

array The set context objects.

Throws

\Drupal\Component\Plugin\Exception\PluginException If contexts are defined but not set.

Overrides ContextAwarePluginInterface::getContexts

4 calls to ContextAwarePluginBase::getContexts()
ContextAwarePluginBase::getCacheContexts in core/lib/Drupal/Core/Plugin/ContextAwarePluginBase.php
ContextAwarePluginBase::getCacheMaxAge in core/lib/Drupal/Core/Plugin/ContextAwarePluginBase.php
ContextAwarePluginBase::getCacheTags in core/lib/Drupal/Core/Plugin/ContextAwarePluginBase.php
ContextAwarePluginBase::validateContexts in core/lib/Drupal/Component/Plugin/ContextAwarePluginBase.php
Validates the set values for the defined contexts.

File

core/lib/Drupal/Component/Plugin/ContextAwarePluginBase.php, line 92
Contains \Drupal\Component\Plugin\ContextAwarePluginBase.

Class

ContextAwarePluginBase
Base class for plugins that are context aware.

Namespace

Drupal\Component\Plugin

Code

public function getContexts() {

  // Make sure all context objects are initialized.
  foreach ($this
    ->getContextDefinitions() as $name => $definition) {
    $this
      ->getContext($name);
  }
  return $this->context;
}