You are here

public function LayoutInfoController::layoutInfoPage in Devel 8

Same name and namespace in other branches
  1. 8.3 src/Controller/LayoutInfoController.php \Drupal\devel\Controller\LayoutInfoController::layoutInfoPage()
  2. 8.2 src/Controller/LayoutInfoController.php \Drupal\devel\Controller\LayoutInfoController::layoutInfoPage()
  3. 4.x src/Controller/LayoutInfoController.php \Drupal\devel\Controller\LayoutInfoController::layoutInfoPage()

Builds the Layout Info page.

Return value

array Array of page elements to render.

1 string reference to 'LayoutInfoController::layoutInfoPage'
devel.routing.yml in ./devel.routing.yml
devel.routing.yml

File

src/Controller/LayoutInfoController.php, line 46

Class

LayoutInfoController
Returns response for Layout Info route.

Namespace

Drupal\devel\Controller

Code

public function layoutInfoPage() {
  $definedLayouts = [];
  $layouts = $this->layoutPluginManager
    ->getDefinitions();
  foreach ($layouts as $layout) {

    // @todo Revisit once https://www.drupal.org/node/2660124 gets in, getting
    // the image should be as simple as $layout->getIcon().
    $image = NULL;
    if ($layout
      ->getIconPath() != NULL) {
      $image = [
        'data' => [
          '#theme' => 'image',
          '#uri' => $layout
            ->getIconPath(),
          '#alt' => $layout
            ->getLabel(),
          '#height' => '65',
        ],
      ];
    }
    $definedLayouts[] = [
      $image,
      $layout
        ->getLabel(),
      $layout
        ->getDescription(),
      $layout
        ->getCategory(),
      implode(', ', $layout
        ->getRegionLabels()),
      $layout
        ->getProvider(),
    ];
  }
  return [
    '#theme' => 'table',
    '#header' => [
      $this
        ->t('Icon'),
      $this
        ->t('Label'),
      $this
        ->t('Description'),
      $this
        ->t('Category'),
      $this
        ->t('Regions'),
      $this
        ->t('Provider'),
    ],
    '#rows' => $definedLayouts,
    '#empty' => $this
      ->t('No layouts available.'),
    '#attributes' => [
      'class' => [
        'devel-layout-list',
      ],
    ],
  ];
}