function ContextAwarePluginTrait::getContext

Same name in other branches
  1. 9 core/lib/Drupal/Core/Plugin/ContextAwarePluginTrait.php \Drupal\Core\Plugin\ContextAwarePluginTrait::getContext()
  2. 10 core/lib/Drupal/Core/Plugin/ContextAwarePluginTrait.php \Drupal\Core\Plugin\ContextAwarePluginTrait::getContext()

Return value

\Drupal\Core\Plugin\Context\ContextInterface The context object.

2 calls to ContextAwarePluginTrait::getContext()
ContextAwarePluginTrait::getContexts in core/lib/Drupal/Core/Plugin/ContextAwarePluginTrait.php
ContextAwarePluginTrait::setContextValue in core/lib/Drupal/Core/Plugin/ContextAwarePluginTrait.php

File

core/lib/Drupal/Core/Plugin/ContextAwarePluginTrait.php, line 48

Class

ContextAwarePluginTrait
Provides a trait to add context-aware functionality to plugins.

Namespace

Drupal\Core\Plugin

Code

public function getContext($name) {
    // Check for a valid context value.
    if (!isset($this->context[$name])) {
        $this->context[$name] = new Context($this->getContextDefinition($name));
    }
    return $this->context[$name];
}

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