public function DesignTestController::categoryPage

Menu 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.

Parameters

string $category: The design test category being currently accessed. Maps to the subdirectory names of this module.

Return value

array A render array containing a menu link tree.

1 string reference to 'DesignTestController::categoryPage'
design_test.routing.yml in drupal/core/modules/system/tests/modules/design_test/design_test.routing.yml
drupal/core/modules/system/tests/modules/design_test/design_test.routing.yml

File

drupal/core/modules/system/tests/modules/design_test/lib/Drupal/design_test/Controller/DesignTestController.php, line 44
Contains \Drupal\design_test\Controller\DesignTestController.

Class

DesignTestController
Controller routines for design_test routes.

Namespace

Drupal\design_test\Controller

Code

public function categoryPage($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;
    }
  }
  return menu_tree_output($tree);
}