Security update for Core, with self-updated composer
[yaffs-website] / web / core / modules / views / src / Plugin / Block / ViewsExposedFilterBlock.php
index 2dd4652a9751094b7abee24d209ab90369a86eeb..4b40a0d31d6a8be44d42e1e92ddd81da1f6bc23c 100644 (file)
@@ -1,6 +1,7 @@
 <?php
 
 namespace Drupal\views\Plugin\Block;
+
 use Drupal\Core\Cache\Cache;
 
 /**
@@ -24,9 +25,23 @@ class ViewsExposedFilterBlock extends ViewsBlockBase {
 
   /**
    * {@inheritdoc}
+   *
+   * @return array
+   *   A renderable array representing the content of the block with additional
+   *   context of current view and display ID.
    */
   public function build() {
     $output = $this->view->display_handler->viewExposedFormBlocks();
+    // Provide the context for block build and block view alter hooks.
+    // \Drupal\views\Plugin\Block\ViewsBlock::build() adds the same context in
+    // \Drupal\views\ViewExecutable::buildRenderable() using
+    // \Drupal\views\Plugin\views\display\DisplayPluginBase::buildRenderable().
+    if (is_array($output) && !empty($output)) {
+      $output += [
+        '#view' => $this->view,
+        '#display_id' => $this->displayID,
+      ];
+    }
 
     // Before returning the block output, convert it to a renderable array with
     // contextual links.