page_layouts-1.0.1/src/Controller/LayoutListController.php

src/Controller/LayoutListController.php
<?php

namespace Drupal\page_layouts\Controller;

use Drupal\Core\Entity\Controller\EntityListController;
use Drupal\Core\Extension\ThemeHandlerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;

/**
 * Defines a controller to list page_layouts_sections.
 */
class LayoutListController extends EntityListController {

  /**
   * The theme handler.
   *
   * @var \Drupal\Core\Extension\ThemeHandlerInterface
   */
  protected $themeHandler;

  /**
   * Constructs the BlockListController.
   *
   * @param \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler
   *   The theme handler.
   */
  public function __construct(ThemeHandlerInterface $theme_handler) {
    $this->themeHandler = $theme_handler;
  }

  /**
   * Shows the page_layouts_section administration page.
   *
   * @param string|null $theme
   *   Theme key of page_layouts_section list.
   * @param \Symfony\Component\HttpFoundation\Request $request
   *   The current request.
   *
   * @return array
   *   A render array as expected by
   *   \Drupal\Core\Render\RendererInterface::render().
   */
  public function listing($theme = NULL, ?Request $request = NULL) {
    $theme = $theme ?: $this->config('system.theme')->get('default');
    if (!$this->themeHandler->hasUi($theme)) {
      throw new NotFoundHttpException();
    }

    return $this->entityTypeManager()->getListBuilder('page_layouts_layout')->render($theme, $request);
  }

}

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

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