Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Context.php

function Context::getContextValue

Same name in this branch
  1. 11.1.x core/lib/Drupal/Component/Plugin/Context/Context.php \Drupal\Component\Plugin\Context\Context::getContextValue()

Overrides Context::getContextValue

File

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

Class

Context
A Drupal specific context wrapper class.

Namespace

Drupal\Core\Plugin\Context

Code

public function getContextValue() {
    if (!isset($this->contextData)) {
        $definition = $this->getContextDefinition();
        $default_value = $definition->getDefaultValue();
        if (isset($default_value)) {
            // Keep the default value here so that subsequent calls don't have to
            // look it up again.
            $this->setContextValue($default_value);
        }
        elseif ($definition->isRequired()) {
            $type = $definition->getDataType();
            throw new ContextException("The '{$type}' context is required and not present.");
        }
        return $default_value;
    }
    return $this->getTypedDataManager()
        ->getCanonicalRepresentation($this->contextData);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal