diff --git a/core/modules/system/tests/modules/design_test/design_test.module b/core/modules/system/tests/modules/design_test/design_test.module index a7ab1b5..f69f961 100644 --- a/core/modules/system/tests/modules/design_test/design_test.module +++ b/core/modules/system/tests/modules/design_test/design_test.module @@ -68,21 +68,19 @@ function design_test_menu() { $items['design_test'] = array( 'title' => 'Design test', - 'page callback' => 'design_test_category_page', - 'page arguments' => array(1), - 'access callback' => TRUE, + 'route_name' => 'design_test', ); + $items['design_test/list'] = array( 'title' => 'List', 'type' => MENU_DEFAULT_LOCAL_TASK, ); + // Lastly, add the category containers. foreach ($categories as $category) { $items["design_test/{$category}"] = array( 'title' => drupal_ucfirst($category), - 'page callback' => 'design_test_category_page', - 'page arguments' => array(1), - 'access callback' => TRUE, + 'route_name' => 'design_test', 'type' => MENU_LOCAL_TASK | MENU_VISIBLE_IN_TREE, ); } @@ -133,36 +131,3 @@ function design_test_menu_local_tasks_alter(&$data, $router_item, $root_path) { function design_test_menu_theme_callback() { return drupal_container()->get('request')->query->get('theme'); } - -/** - * Menu page callback for a category listing page. - * - * This is a specialized version of system_admin_menu_block_page(), which - * retrieves all direct child menu links of the current page, regardless of - * their type, skips default local tasks, and outputs them as a simple menu - * tree as the main page content. - * - * @param string $category - * The design test category being currently accessed. Maps to the subdirectory - * names of this module. - * - * @return array - * A render array containing a menu link tree. - */ -function design_test_category_page($category) { - $link = menu_link_get_preferred(); - $tree = menu_build_tree($link['menu_name'], array( - 'expanded' => array($link['mlid']), - 'min_depth' => $link['depth'] + 1, - 'max_depth' => $link['depth'] + 2, - )); - // Local tasks are hidden = -1, so normally not rendered in menu trees. - foreach ($tree as &$data) { - // Exclude default local tasks. - if (!($data['link']['type'] & MENU_LINKS_TO_PARENT)) { - $data['link']['hidden'] = 0; - } - } - $build = menu_tree_output($tree); - return $build; -} diff --git a/core/modules/system/tests/modules/design_test/design_test.routing.yml b/core/modules/system/tests/modules/design_test/design_test.routing.yml new file mode 100644 index 0000000..1262be4 --- /dev/null +++ b/core/modules/system/tests/modules/design_test/design_test.routing.yml @@ -0,0 +1,7 @@ +design_test: + pattern: '/design_test/{category}' + defaults: + _content: '\Drupal\design_test\Controller\DesignTestController::categoryPage' + category: 'FALSE' + requirements: + _access: 'TRUE' diff --git a/core/modules/system/tests/modules/design_test/lib/Drupal/design_test/Controller/DesignTestController.php b/core/modules/system/tests/modules/design_test/lib/Drupal/design_test/Controller/DesignTestController.php new file mode 100644 index 0000000..4a099b4 --- /dev/null +++ b/core/modules/system/tests/modules/design_test/lib/Drupal/design_test/Controller/DesignTestController.php @@ -0,0 +1,62 @@ + array($link['mlid']), + 'min_depth' => $link['depth'] + 1, + 'max_depth' => $link['depth'] + 2, + )); + // Local tasks are hidden = -1, so normally not rendered in menu trees. + foreach ($tree as &$data) { + // Exclude default local tasks. + if (!($data['link']['type'] & MENU_LINKS_TO_PARENT)) { + $data['link']['hidden'] = 0; + } + } + $build = menu_tree_output($tree); + return $build; + } + +}