You are here

public function DisplayPluginBase::viewExposedFormBlocks in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/views/src/Plugin/views/display/DisplayPluginBase.php \Drupal\views\Plugin\views\display\DisplayPluginBase::viewExposedFormBlocks()

Renders the exposed form as block.

Return value

string|null The rendered exposed form as string or NULL otherwise.

Overrides DisplayPluginInterface::viewExposedFormBlocks

File

core/modules/views/src/Plugin/views/display/DisplayPluginBase.php, line 2623

Class

DisplayPluginBase
Base class for views display plugins.

Namespace

Drupal\views\Plugin\views\display

Code

public function viewExposedFormBlocks() {

  // Avoid interfering with the admin forms.
  $route_name = \Drupal::routeMatch()
    ->getRouteName();
  if (strpos($route_name, 'views_ui.') === 0) {
    return;
  }
  $this->view
    ->initHandlers();
  if ($this
    ->usesExposed() && $this
    ->getOption('exposed_block')) {

    /** @var \Drupal\views\Plugin\views\exposed_form\ExposedFormPluginInterface $exposed_form */
    $exposed_form = $this
      ->getPlugin('exposed_form');
    return $exposed_form
      ->renderExposedForm(TRUE);
  }
}