You are here

public function Context::getContextData in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Core/Plugin/Context/Context.php \Drupal\Core\Plugin\Context\Context::getContextData()

Gets the context value as typed data object.

Return value

\Drupal\Core\TypedData\TypedDataInterface

Overrides ContextInterface::getContextData

File

core/lib/Drupal/Core/Plugin/Context/Context.php, line 120
Contains \Drupal\Core\Plugin\Context\Context.

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