2dd4652a9751094b7abee24d209ab90369a86eeb
[yaffs-website] / web / core / modules / views / src / Plugin / Block / ViewsExposedFilterBlock.php
1 <?php
2
3 namespace Drupal\views\Plugin\Block;
4 use Drupal\Core\Cache\Cache;
5
6 /**
7  * Provides a 'Views Exposed Filter' block.
8  *
9  * @Block(
10  *   id = "views_exposed_filter_block",
11  *   admin_label = @Translation("Views Exposed Filter Block"),
12  *   deriver = "Drupal\views\Plugin\Derivative\ViewsExposedFilterBlock"
13  * )
14  */
15 class ViewsExposedFilterBlock extends ViewsBlockBase {
16
17   /**
18    * {@inheritdoc}
19    */
20   public function getCacheContexts() {
21     $contexts = $this->view->display_handler->getCacheMetadata()->getCacheContexts();
22     return Cache::mergeContexts(parent::getCacheContexts(), $contexts);
23   }
24
25   /**
26    * {@inheritdoc}
27    */
28   public function build() {
29     $output = $this->view->display_handler->viewExposedFormBlocks();
30
31     // Before returning the block output, convert it to a renderable array with
32     // contextual links.
33     $this->addContextualLinks($output, 'exposed_filter');
34
35     return $output;
36   }
37
38 }