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

Breadcrumb

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

function ContextAwarePluginTrait::setContext

3 calls to ContextAwarePluginTrait::setContext()
ContextAwarePluginTrait::setContextValue in core/lib/Drupal/Core/Plugin/ContextAwarePluginTrait.php
DefaultsSectionStorage::setContext in core/modules/layout_builder/src/Plugin/SectionStorage/DefaultsSectionStorage.php
DefaultsSectionStorage::setContext in core/modules/layout_builder/src/Plugin/SectionStorage/DefaultsSectionStorage.php
1 method overrides ContextAwarePluginTrait::setContext()
DefaultsSectionStorage::setContext in core/modules/layout_builder/src/Plugin/SectionStorage/DefaultsSectionStorage.php

File

core/lib/Drupal/Core/Plugin/ContextAwarePluginTrait.php, line 59

Class

ContextAwarePluginTrait
Provides a trait to add context-aware functionality to plugins.

Namespace

Drupal\Core\Plugin

Code

public function setContext($name, ComponentContextInterface $context) {
    // Check that the context passed is an instance of our extended interface.
    if (!$context instanceof ContextInterface) {
        throw new ContextException("Passed {$name} context must be an instance of \\Drupal\\Core\\Plugin\\Context\\ContextInterface");
    }
    $this->context[$name] = $context;
}

API Navigation

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