class ContextAwarePluginBase

Same name in this branch
  1. 9 core/lib/Drupal/Component/Plugin/ContextAwarePluginBase.php \Drupal\Component\Plugin\ContextAwarePluginBase
Same name and namespace in other branches
  1. 8.9.x core/lib/Drupal/Core/Plugin/ContextAwarePluginBase.php \Drupal\Core\Plugin\ContextAwarePluginBase
  2. 8.9.x core/lib/Drupal/Component/Plugin/ContextAwarePluginBase.php \Drupal\Component\Plugin\ContextAwarePluginBase

Base class for plugins that are context aware.

Hierarchy

Expanded class hierarchy of ContextAwarePluginBase

Deprecated

in drupal:9.1.0 and is removed from drupal:10.0.0. Use \Drupal\Core\Plugin\ContextAwarePluginTrait instead.

See also

https://www.drupal.org/node/3120980

1 file declares its use of ContextAwarePluginBase
ContextAwarePluginBaseTest.php in core/tests/Drupal/KernelTests/Core/Plugin/Context/ContextAwarePluginBaseTest.php

File

core/lib/Drupal/Core/Plugin/ContextAwarePluginBase.php, line 22

Namespace

Drupal\Core\Plugin
View source
abstract class ContextAwarePluginBase extends ComponentContextAwarePluginBase implements ContextAwarePluginInterface, CacheableDependencyInterface {
  use ContextAwarePluginTrait;
  use TypedDataTrait;
  use StringTranslationTrait;
  use DependencySerializationTrait;
  
  /**
   * {@inheritdoc}
   *
   * @return \Drupal\Core\Plugin\Context\ContextInterface[]
   */
  protected function createContextFromConfiguration(array $context_configuration) {
    // This method is overridden so that it will use
    // \Drupal\Core\Plugin\Context\Context instead.
    $contexts = [];
    foreach ($context_configuration as $key => $value) {
      $context_definition = $this->getContextDefinition($key);
      $contexts[$key] = new Context($context_definition, $value);
    }
    return $contexts;
  }

}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.