class TestPageDisplayVariantSubscriber in Drupal 10
Same name and namespace in other branches
- 8 core/modules/system/tests/modules/display_variant_test/src/EventSubscriber/TestPageDisplayVariantSubscriber.php \Drupal\display_variant_test\EventSubscriber\TestPageDisplayVariantSubscriber
- 9 core/modules/system/tests/modules/display_variant_test/src/EventSubscriber/TestPageDisplayVariantSubscriber.php \Drupal\display_variant_test\EventSubscriber\TestPageDisplayVariantSubscriber
Selects the test page display variant.
Hierarchy
- class \Drupal\display_variant_test\EventSubscriber\TestPageDisplayVariantSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
Expanded class hierarchy of TestPageDisplayVariantSubscriber
1 string reference to 'TestPageDisplayVariantSubscriber'
- display_variant_test.services.yml in core/
modules/ system/ tests/ modules/ display_variant_test/ display_variant_test.services.yml - core/modules/system/tests/modules/display_variant_test/display_variant_test.services.yml
1 service uses TestPageDisplayVariantSubscriber
- display_variant_test.page_display_variant_subscriber in core/
modules/ system/ tests/ modules/ display_variant_test/ display_variant_test.services.yml - Drupal\display_variant_test\EventSubscriber\TestPageDisplayVariantSubscriber
File
- core/
modules/ system/ tests/ modules/ display_variant_test/ src/ EventSubscriber/ TestPageDisplayVariantSubscriber.php, line 14
Namespace
Drupal\display_variant_test\EventSubscriberView source
class TestPageDisplayVariantSubscriber implements EventSubscriberInterface {
/**
* Selects the page display variant.
*
* @param \Drupal\Core\Render\PageDisplayVariantSelectionEvent $event
* The event to process.
*/
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,
]);
}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() : array {
$events[RenderEvents::SELECT_PAGE_DISPLAY_VARIANT][] = [
'onSelectPageDisplayVariant',
];
return $events;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
TestPageDisplayVariantSubscriber:: |
public static | function | ||
TestPageDisplayVariantSubscriber:: |
public | function | Selects the page display variant. |