function TestPageDisplayVariantSubscriber::onSelectPageDisplayVariant
Same name in other branches
- 8.9.x core/modules/system/tests/modules/display_variant_test/src/EventSubscriber/TestPageDisplayVariantSubscriber.php \Drupal\display_variant_test\EventSubscriber\TestPageDisplayVariantSubscriber::onSelectPageDisplayVariant()
- 10 core/modules/system/tests/modules/display_variant_test/src/EventSubscriber/TestPageDisplayVariantSubscriber.php \Drupal\display_variant_test\EventSubscriber\TestPageDisplayVariantSubscriber::onSelectPageDisplayVariant()
- 11.x 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\EventSubscriberCode
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,
]);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.