8.5.x ContextAwarePluginBase.php ContextAwarePluginBase::getContexts()
8.0.x ContextAwarePluginBase.php ContextAwarePluginBase::getContexts()
8.1.x ContextAwarePluginBase.php ContextAwarePluginBase::getContexts()
8.2.x ContextAwarePluginBase.php ContextAwarePluginBase::getContexts()
8.3.x ContextAwarePluginBase.php ContextAwarePluginBase::getContexts()
8.4.x ContextAwarePluginBase.php ContextAwarePluginBase::getContexts()
8.6.x ContextAwarePluginBase.php 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

File

core/lib/Drupal/Component/Plugin/ContextAwarePluginBase.php, line 87

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;
}