You are here

public function LayoutController::layoutPageList in Layout 8.2

Presents a list of layouts.

Return value

array A form array as expected by drupal_render().

1 string reference to 'LayoutController::layoutPageList'
layout.routing.yml in ./layout.routing.yml
layout.routing.yml

File

lib/Drupal/layout/Controller/LayoutController.php, line 52
Contains \Drupal\layout\Controller\LayoutController.

Class

LayoutController
Controller routines for layout routes.

Namespace

Drupal\layout\Controller

Code

public function layoutPageList() {

  // Get list of layouts defined by enabled modules and themes.
  $layouts = $this->layoutManager
    ->getDefinitions();
  $rows = array();
  $header = array(
    t('Name'),
    t('Source'),
  );
  foreach ($layouts as $name => $layout) {

    // @todo Cache result of system_get_info().
    $provider_info = system_get_info($layout['provider']['type'], $layout['provider']['provider']);

    // Build table columns for this row.
    $row = array();
    $row['name'] = l($layout['title'], 'admin/structure/templates/manage/' . $name);

    // Type can either be 'module' or 'theme'.
    $row['provider'] = t('%name @type', array(
      '%name' => $provider_info['name'],
      '@type' => t($layout['provider']['type']),
    ));
    $rows[] = $row;
  }
  $build = array();
  $build['table'] = array(
    '#theme' => 'table',
    '#header' => $header,
    '#rows' => $rows,
    '#empty' => t('No layouts defined'),
  );
  return $build;

  // Ensure the provider types are translatable. These do not need to run,
  // just inform the static code parser of these source strings.
  t('module');
  t('theme');
}