8.5.x ContextAwarePluginBase.php ContextAwarePluginBase::getContextValues()
8.0.x ContextAwarePluginBase.php ContextAwarePluginBase::getContextValues()
8.1.x ContextAwarePluginBase.php ContextAwarePluginBase::getContextValues()
8.2.x ContextAwarePluginBase.php ContextAwarePluginBase::getContextValues()
8.3.x ContextAwarePluginBase.php ContextAwarePluginBase::getContextValues()
8.4.x ContextAwarePluginBase.php ContextAwarePluginBase::getContextValues()
8.6.x ContextAwarePluginBase.php ContextAwarePluginBase::getContextValues()

Gets the values for all defined contexts.

Return value

array An array of set context values, keyed by context name. If a context is unset its value is returned as NULL.

Overrides ContextAwarePluginInterface::getContextValues

File

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

Class

ContextAwarePluginBase
Base class for plugins that are context aware.

Namespace

Drupal\Component\Plugin

Code

public function getContextValues() {
  $values = [];
  foreach ($this
    ->getContextDefinitions() as $name => $definition) {
    $values[$name] = isset($this->context[$name]) ? $this->context[$name]
      ->getContextValue() : NULL;
  }
  return $values;
}