Version 1
[yaffs-website] / web / core / modules / views / src / Plugin / Block / ViewsExposedFilterBlock.php
diff --git a/web/core/modules/views/src/Plugin/Block/ViewsExposedFilterBlock.php b/web/core/modules/views/src/Plugin/Block/ViewsExposedFilterBlock.php
new file mode 100644 (file)
index 0000000..2dd4652
--- /dev/null
@@ -0,0 +1,38 @@
+<?php
+
+namespace Drupal\views\Plugin\Block;
+use Drupal\Core\Cache\Cache;
+
+/**
+ * Provides a 'Views Exposed Filter' block.
+ *
+ * @Block(
+ *   id = "views_exposed_filter_block",
+ *   admin_label = @Translation("Views Exposed Filter Block"),
+ *   deriver = "Drupal\views\Plugin\Derivative\ViewsExposedFilterBlock"
+ * )
+ */
+class ViewsExposedFilterBlock extends ViewsBlockBase {
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getCacheContexts() {
+    $contexts = $this->view->display_handler->getCacheMetadata()->getCacheContexts();
+    return Cache::mergeContexts(parent::getCacheContexts(), $contexts);
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function build() {
+    $output = $this->view->display_handler->viewExposedFormBlocks();
+
+    // Before returning the block output, convert it to a renderable array with
+    // contextual links.
+    $this->addContextualLinks($output, 'exposed_filter');
+
+    return $output;
+  }
+
+}