function Context::createFromContext

Same name in other branches
  1. 9 core/lib/Drupal/Core/Plugin/Context/Context.php \Drupal\Core\Plugin\Context\Context::createFromContext()
  2. 8.9.x core/lib/Drupal/Core/Plugin/Context/Context.php \Drupal\Core\Plugin\Context\Context::createFromContext()
  3. 11.x core/lib/Drupal/Core/Plugin/Context/Context.php \Drupal\Core\Plugin\Context\Context::createFromContext()

Overrides ContextInterface::createFromContext

2 calls to Context::createFromContext()
ContextAwarePluginTrait::setContextValue in core/lib/Drupal/Core/Plugin/ContextAwarePluginTrait.php
ContextTest::testSetContextValueCacheableDependency in core/tests/Drupal/Tests/Core/Plugin/Context/ContextTest.php
@covers ::setContextValue

File

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

Class

Context
A Drupal specific context wrapper class.

Namespace

Drupal\Core\Plugin\Context

Code

public static function createFromContext(ContextInterface $old_context, $value) {
    $context = new static($old_context->getContextDefinition(), $value);
    $context->addCacheableDependency($old_context);
    if (method_exists($old_context, 'getTypedDataManager')) {
        $context->setTypedDataManager($old_context->getTypedDataManager());
    }
    return $context;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.