function Context::getContextData

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Plugin/Context/Context.php \Drupal\Core\Plugin\Context\Context::getContextData()
  2. 10 core/lib/Drupal/Core/Plugin/Context/Context.php \Drupal\Core\Plugin\Context\Context::getContextData()
  3. 11.x core/lib/Drupal/Core/Plugin/Context/Context.php \Drupal\Core\Plugin\Context\Context::getContextData()

Overrides ContextInterface::getContextData

File

core/lib/Drupal/Core/Plugin/Context/Context.php, line 117

Class

Context
A Drupal specific context wrapper class.

Namespace

Drupal\Core\Plugin\Context

Code

public function getContextData() {
    if (!isset($this->contextData)) {
        $definition = $this->getContextDefinition();
        $default_value = $definition->getDefaultValue();
        // Store the default value so that subsequent calls don't have to look
        // it up again.
        $this->contextData = $this->getTypedDataManager()
            ->create($definition->getDataDefinition(), $default_value);
    }
    return $this->contextData;
}

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