From 0db6843c248d8a10e1d05d58a6ce1ffdbd120ddd Mon Sep 17 00:00:00 2001 From: Alex Pott Date: Fri, 28 Apr 2017 14:36:17 +0100 Subject: [PATCH] Issue #2847657 by jibran, xjm: ViewsBlockBase doesn't expose parent view and display info --- .../src/Plugin/Block/ViewsExposedFilterBlock.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/core/modules/views/src/Plugin/Block/ViewsExposedFilterBlock.php b/core/modules/views/src/Plugin/Block/ViewsExposedFilterBlock.php index 2dd4652a975..ec066ab64e6 100644 --- a/core/modules/views/src/Plugin/Block/ViewsExposedFilterBlock.php +++ b/core/modules/views/src/Plugin/Block/ViewsExposedFilterBlock.php @@ -24,9 +24,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.