domain_views_display-1.x-dev/tests/modules/domain_views_display_test/src/TestController.php

tests/modules/domain_views_display_test/src/TestController.php
<?php

declare(strict_types=1);

namespace Drupal\domain_views_display_test;

use Drupal\Core\Controller\ControllerBase;
use Drupal\views\Views;

/**
 * Provides test pages.
 */
class TestController extends ControllerBase {

  /**
   * Returns views data without views theming.
   *
   * @return array<string, mixed>
   *   A render array with the view header and rows and possibly title.
   */
  public function directView(): array {
    $view = Views::getView('domain_views_display_test');
    assert($view !== NULL);
    $view->setDisplay('page_overridden');
    /** @var array{'#rows': array<int|string, mixed>, '#title'?: array{'#markup': string|\Drupal\Component\Render\MarkupInterface}} $build */
    $build = $view->executeDisplay('page_overridden');
    $header = $view->display_handler->renderArea('header');

    $out = [];
    if (isset($build['#title'])) {
      $out['title'] = [
        '#type' => 'html_tag',
        '#tag' => 'h1',
        '#value' => $build['#title']['#markup'],
      ];
    }

    return $out + [
      'header' => $header,
      'rows' => $build['#rows'],
    ];
  }

}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc