public function Context::getContextValue in Zircon Profile 8
Same name in this branch
- 8 core/lib/Drupal/Core/Plugin/Context/Context.php \Drupal\Core\Plugin\Context\Context::getContextValue()
- 8 core/lib/Drupal/Component/Plugin/Context/Context.php \Drupal\Component\Plugin\Context\Context::getContextValue()
Same name and namespace in other branches
- 8.0 core/lib/Drupal/Core/Plugin/Context/Context.php \Drupal\Core\Plugin\Context\Context::getContextValue()
Gets the context value.
Return value
mixed The currently set context value, or NULL if it is not set.
Overrides Context::getContextValue
File
- core/
lib/ Drupal/ Core/ Plugin/ Context/ Context.php, line 64 - Contains \Drupal\Core\Plugin\Context\Context.
Class
- Context
- A Drupal specific context wrapper class.
Namespace
Drupal\Core\Plugin\ContextCode
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);
}