You are here

public function DefaultsSectionStorage::setContext in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/layout_builder/src/Plugin/SectionStorage/DefaultsSectionStorage.php \Drupal\layout_builder\Plugin\SectionStorage\DefaultsSectionStorage::setContext()

Set a context on this plugin.

Parameters

string $name: The name of the context in the plugin configuration.

\Drupal\Component\Plugin\Context\ContextInterface $context: The context object to set.

Overrides ContextAwarePluginTrait::setContext

File

core/modules/layout_builder/src/Plugin/SectionStorage/DefaultsSectionStorage.php, line 397

Class

DefaultsSectionStorage
Defines the 'defaults' section storage type.

Namespace

Drupal\layout_builder\Plugin\SectionStorage

Code

public function setContext($name, ComponentContextInterface $context) {

  // Set the view mode context based on the display context.
  if ($name === 'display') {
    $this
      ->setContextValue('view_mode', $context
      ->getContextValue()
      ->getMode());
  }
  parent::setContext($name, $context);
}