You are here

class TestPageDisplayVariantSubscriber in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 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

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 19
Contains \Drupal\display_variant_test\EventSubscriber\TestPageDisplayVariantSubscriber.

Namespace

Drupal\display_variant_test\EventSubscriber
View 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}
   */
  static function getSubscribedEvents() {
    $events[RenderEvents::SELECT_PAGE_DISPLAY_VARIANT][] = array(
      'onSelectPageDisplayVariant',
    );
    return $events;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
TestPageDisplayVariantSubscriber::getSubscribedEvents static function Returns an array of event names this subscriber wants to listen to. Overrides EventSubscriberInterface::getSubscribedEvents
TestPageDisplayVariantSubscriber::onSelectPageDisplayVariant public function Selects the page display variant.