You are here

public function LayoutController::layoutPageView in Layout 8.2

Demonstrates a layout template.

Parameters

string $key: The key of the page layout being requested.

Return value

array An array as expected by drupal_render().

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

File

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

Class

LayoutController
Controller routines for layout routes.

Namespace

Drupal\layout\Controller

Code

public function layoutPageView($key) {

  // Render the layout in an admin context with region demonstrations.
  $instance = $this->layoutManager
    ->createInstance($key, array());
  $regions = $instance
    ->getRegions();
  foreach ($regions as $region => $info) {
    $regions[$region] = '<div class="layout-region-demonstration">' . String::checkPlain($info['label']) . '</div>';
  }
  $build['demonstration']['#markup'] = $instance
    ->renderLayout(TRUE, $regions);
  $layout = $this->layoutManager
    ->getDefinition($key);
  $build['#title'] = t('View template %name', array(
    '%name' => $layout['title'],
  ));

  // @todo Convert layout.admin.css to a library.
  $build['#attached']['css'][] = drupal_get_path('module', 'layout') . '/css/layout.admin.css';
  return $build;
}