public function Context::getContextValue

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

Overrides \Drupal\Component\Plugin\Context\Context::getContextValue().

Overrides Context::getContextValue

1 call to Context::getContextValue()
Context::validate in drupal/core/lib/Drupal/Core/Plugin/Context/Context.php
Overrides \Drupal\Component\Plugin\Context\Context::getConstraints().

File

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

Class

Context
A Drupal specific context wrapper class.

Namespace

Drupal\Core\Plugin\Context

Code

public function getContextValue() {
  $typed_value = parent::getContextValue();

  // If the typed data is complex, pass it on as typed data. Else pass on its
  // plain value, such that e.g. a string will be directly returned as PHP
  // string.
  $is_complex = $typed_value instanceof ComplexDataInterface;
  if (!$is_complex && $typed_value instanceof ListInterface) {
    $is_complex = $typed_value[0] instanceof ComplexDataInterface;
  }

  // @todo We won't need the getType == entity check once #1868004 lands.
  if ($typed_value instanceof TypedDataInterface && (!$is_complex || $typed_value instanceof EntityWrapper)) {
    return $typed_value
      ->getValue();
  }
  return $typed_value;
}