public function ViewsBlock::build

Builds and returns the renderable array for this block plugin.

Return value

array A renderable array representing the content of the block.

Overrides BlockPluginInterface::build

See also

\Drupal\block\BlockRenderController

1 method overrides ViewsBlock::build()
ViewsExposedFilterBlock::build in drupal/core/modules/views/lib/Drupal/views/Plugin/Block/ViewsExposedFilterBlock.php
Builds and returns the renderable array for this block plugin.

File

drupal/core/modules/views/lib/Drupal/views/Plugin/Block/ViewsBlock.php, line 74
Contains \Drupal\views\Plugin\Block\ViewsBlock.

Class

ViewsBlock
Provides a generic Views block.

Namespace

Drupal\views\Plugin\Block

Code

public function build() {
  if ($output = $this->view
    ->executeDisplay($this->displayID)) {
    $output = $this->view
      ->executeDisplay($this->displayID);

    // Set the label to the title configured in the view.
    $this->configuration['label'] = filter_xss_admin($this->view
      ->getTitle());

    // Before returning the block output, convert it to a renderable array
    // with contextual links.
    $this
      ->addContextualLinks($output);
    $this->view
      ->destroy();
    return $output;
  }
  return array();
}