Version 1
[yaffs-website] / web / core / modules / block / src / EventSubscriber / BlockPageDisplayVariantSubscriber.php
diff --git a/web/core/modules/block/src/EventSubscriber/BlockPageDisplayVariantSubscriber.php b/web/core/modules/block/src/EventSubscriber/BlockPageDisplayVariantSubscriber.php
new file mode 100644 (file)
index 0000000..89f361f
--- /dev/null
@@ -0,0 +1,34 @@
+<?php
+
+namespace Drupal\block\EventSubscriber;
+
+use Drupal\Core\Render\PageDisplayVariantSelectionEvent;
+use Drupal\Core\Render\RenderEvents;
+use Symfony\Component\EventDispatcher\EventSubscriberInterface;
+
+/**
+ * Selects the block page display variant.
+ *
+ * @see \Drupal\block\Plugin\DisplayVariant\BlockPageVariant
+ */
+class BlockPageDisplayVariantSubscriber implements EventSubscriberInterface {
+
+  /**
+   * Selects the block page display variant.
+   *
+   * @param \Drupal\Core\Render\PageDisplayVariantSelectionEvent $event
+   *   The event to process.
+   */
+  public function onSelectPageDisplayVariant(PageDisplayVariantSelectionEvent $event) {
+    $event->setPluginId('block_page');
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public static function getSubscribedEvents() {
+    $events[RenderEvents::SELECT_PAGE_DISPLAY_VARIANT][] = ['onSelectPageDisplayVariant'];
+    return $events;
+  }
+
+}