You are here

public function Page::execute in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/views/src/Plugin/views/display/Page.php \Drupal\views\Plugin\views\display\Page::execute()
  2. 9 core/modules/views/src/Plugin/views/display/Page.php \Drupal\views\Plugin\views\display\Page::execute()

Executes the view and returns data in the format required.

The base class cannot be executed.

Overrides PathPluginBase::execute

File

core/modules/views/src/Plugin/views/display/Page.php, line 191

Class

Page
The plugin that handles a full page.

Namespace

Drupal\views\Plugin\views\display

Code

public function execute() {
  parent::execute();

  // And now render the view.
  $render = $this->view
    ->render();

  // First execute the view so it's possible to get tokens for the title.
  // And the title, which is much easier.
  // @todo Figure out how to support custom response objects. Maybe for pages
  //   it should be dropped.
  if (is_array($render)) {
    $render += [
      '#title' => [
        '#markup' => $this->view
          ->getTitle(),
        '#allowed_tags' => Xss::getHtmlTagList(),
      ],
    ];
  }
  return $render;
}