diff --git a/core/modules/layout/layout.admin.inc b/core/modules/layout/layout.admin.inc index 9a1a9213d72068bfce85f081ac04faf0c80bcee3..797c4c74e3d36b30bc7c92d5a84c47cdc5649b0b 100644 --- a/core/modules/layout/layout.admin.inc +++ b/core/modules/layout/layout.admin.inc @@ -5,46 +5,6 @@ * Administration functions for layouts. */ -/** - * Page callback: Presents a list of layouts. - * - * @return array - * An array as expected by drupal_render(). - * - * @see layout_menu() - */ -function layout_page_list() { - // Get list of layouts defined by enabled modules and themes. - $layouts = layout_manager()->getDefinitions(); - - $rows = array(); - $header = array(t('Name'), t('Source')); - foreach ($layouts as $name => $layout) { - $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, - ); - 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'); -} - /** * Page callback: Demonstrates a layout template. * diff --git a/core/modules/layout/layout.module b/core/modules/layout/layout.module index c6ed7ae5612d76c987eebb4aadd5c95c7790e344..17acc6d44c8290fbc10e8cdf8135655fe64dc115 100644 --- a/core/modules/layout/layout.module +++ b/core/modules/layout/layout.module @@ -12,10 +12,7 @@ function layout_menu() { $items['admin/structure/templates'] = array( 'title' => 'Templates', 'description' => 'Overview of the list of layout templates available.', - 'page callback' => 'layout_page_list', - 'access callback' => 'user_access', - 'access arguments' => array('administer layouts'), - 'file' => 'layout.admin.inc', + 'route_name' => 'layout_page_list', ); $items['admin/structure/templates/manage/%'] = array( 'title' => 'View template', diff --git a/core/modules/layout/layout.routing.yml b/core/modules/layout/layout.routing.yml new file mode 100644 index 0000000000000000000000000000000000000000..d1cd540ac34314abb498dc03c6c6c06d1dd6e57e --- /dev/null +++ b/core/modules/layout/layout.routing.yml @@ -0,0 +1,6 @@ +layout_page_list: + pattern: '/admin/structure/templates' + defaults: + _content: '\Drupal\layout\Controller\LayoutController::layoutPageList' + requirements: + _permission: 'administer layouts' diff --git a/core/modules/layout/lib/Drupal/layout/Controller/LayoutController.php b/core/modules/layout/lib/Drupal/layout/Controller/LayoutController.php new file mode 100644 index 0000000000000000000000000000000000000000..848ec02ecd7214df0c2fb779b801bb0e981ef59b --- /dev/null +++ b/core/modules/layout/lib/Drupal/layout/Controller/LayoutController.php @@ -0,0 +1,79 @@ +<?php +/** + * @file + * Contains \Drupal\layout\Controller\LayoutController. + */ + +namespace Drupal\layout\Controller; + +use Drupal\Core\ControllerInterface; +use Drupal\layout\Plugin\Type\LayoutManager; +use Symfony\Component\DependencyInjection\ContainerInterface; + +/** + * Controller routines for layout routes. + */ +class LayoutController implements ControllerInterface { + + /** + * Stores the Layout manager. + * + * @var \Drupal\layout\Plugin\Type\LayoutManager + */ + protected $layoutManager; + + /** + * Constructs a \Drupal\layout\Controller\LayoutController object. + * + * @param \Drupal\layout\Plugin\Type\LayoutManager $layout_manager + * The Layout manager. + */ + function __construct(LayoutManager $layout_manager) { + $this->layoutManager = $layout_manager; + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container) { + return new static($container->get('plugin.manager.layout')); + } + + /** + * Presents a list of layouts. + * + * @return array + * A form array as expected by drupal_render(). + */ + 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) { + $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, + ); + 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'); + } +}