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

Breadcrumb

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

function Context::setContextValue

Sets the context value.

Parameters

mixed $value: The value of this context, matching the context definition.

2 calls to Context::setContextValue()
Context::getContextValue in core/lib/Drupal/Core/Plugin/Context/Context.php
Gets the context value.
Context::__construct in core/lib/Drupal/Core/Plugin/Context/Context.php
Create a context object.

File

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

Class

Context
A Drupal specific context wrapper class.

Namespace

Drupal\Core\Plugin\Context

Code

protected function setContextValue($value) {
    // Add the value as a cacheable dependency only if implements the interface
    // to prevent it from disabling caching with a max-age 0.
    if ($value instanceof CacheableDependencyInterface) {
        $this->addCacheableDependency($value);
    }
    if ($value instanceof TypedDataInterface) {
        $this->contextData = $value;
    }
    else {
        $this->contextData = $this->getTypedDataManager()
            ->create($this->contextDefinition
            ->getDataDefinition(), $value);
    }
}

API Navigation

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