You are here

public function TestPageDisplayVariantSubscriber::onSelectPageDisplayVariant in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/system/tests/modules/display_variant_test/src/EventSubscriber/TestPageDisplayVariantSubscriber.php \Drupal\display_variant_test\EventSubscriber\TestPageDisplayVariantSubscriber::onSelectPageDisplayVariant()
  2. 9 core/modules/system/tests/modules/display_variant_test/src/EventSubscriber/TestPageDisplayVariantSubscriber.php \Drupal\display_variant_test\EventSubscriber\TestPageDisplayVariantSubscriber::onSelectPageDisplayVariant()

Selects the page display variant.

Parameters

\Drupal\Core\Render\PageDisplayVariantSelectionEvent $event: The event to process.

File

core/modules/system/tests/modules/display_variant_test/src/EventSubscriber/TestPageDisplayVariantSubscriber.php, line 22

Class

TestPageDisplayVariantSubscriber
Selects the test page display variant.

Namespace

Drupal\display_variant_test\EventSubscriber

Code

public function onSelectPageDisplayVariant(PageDisplayVariantSelectionEvent $event) {
  $event
    ->setPluginId('display_variant_test');
  $event
    ->setPluginConfiguration([
    'required_configuration' => 'A very important, required value.',
  ]);
  $event
    ->addCacheTags([
    'custom_cache_tag',
  ]);
  $context = new Context(new ContextDefinition('string', NULL, TRUE), 'Explicitly passed in context.');
  $event
    ->setContexts([
    'context' => $context,
  ]);
}