function SystemController::overview

Same name in other branches
  1. 9 core/modules/system/src/Controller/SystemController.php \Drupal\system\Controller\SystemController::overview()
  2. 8.9.x core/modules/system/src/Controller/SystemController.php \Drupal\system\Controller\SystemController::overview()
  3. 11.x core/modules/system/src/Controller/SystemController.php \Drupal\system\Controller\SystemController::overview()

Provide the administration overview page.

This will render child links two levels below the specified link ID, grouped by the child links one level below.

Parameters

string $link_id: The ID of the administrative path link for which to display child links.

Return value

array A renderable array of the administration overview page.

2 string references to 'SystemController::overview'
menu_test.routing.yml in core/modules/system/tests/modules/menu_test/menu_test.routing.yml
core/modules/system/tests/modules/menu_test/menu_test.routing.yml
system.routing.yml in core/modules/system/system.routing.yml
core/modules/system/system.routing.yml

File

core/modules/system/src/Controller/SystemController.php, line 120

Class

SystemController
Returns responses for System routes.

Namespace

Drupal\system\Controller

Code

public function overview($link_id) {
    // Check for status report errors.
    if ($this->currentUser()
        ->hasPermission('administer site configuration') && $this->systemManager
        ->checkRequirements()) {
        $this->messenger()
            ->addError($this->t('One or more problems were detected with your Drupal installation. Check the <a href=":status">status report</a> for more information.', [
            ':status' => Url::fromRoute('system.status')->toString(),
        ]));
    }
    // Load all menu links below it.
    $parameters = new MenuTreeParameters();
    $parameters->setRoot($link_id)
        ->excludeRoot()
        ->setTopLevelOnly()
        ->onlyEnabledLinks();
    $tree = $this->menuLinkTree
        ->load(NULL, $parameters);
    $manipulators = [
        [
            'callable' => 'menu.default_tree_manipulators:checkAccess',
        ],
        [
            'callable' => 'menu.default_tree_manipulators:generateIndexAndSort',
        ],
    ];
    $tree = $this->menuLinkTree
        ->transform($tree, $manipulators);
    $tree_access_cacheability = new CacheableMetadata();
    $blocks = [];
    foreach ($tree as $key => $element) {
        $tree_access_cacheability = $tree_access_cacheability->merge(CacheableMetadata::createFromObject($element->access));
        // Only render accessible links.
        if (!$element->access
            ->isAllowed()) {
            continue;
        }
        $link = $element->link;
        $block['title'] = $link->getTitle();
        $block['description'] = $link->getDescription();
        $block['content'] = [
            '#theme' => 'admin_block_content',
            '#content' => $this->systemManager
                ->getAdminBlock($link),
        ];
        if (!empty($block['content']['#content'])) {
            $blocks[$key] = $block;
        }
    }
    if ($blocks) {
        ksort($blocks);
        $build = [
            '#theme' => 'admin_page',
            '#blocks' => $blocks,
        ];
        $tree_access_cacheability->applyTo($build);
        return $build;
    }
    else {
        $build = [
            '#markup' => $this->t('You do not have any administrative items.'),
        ];
        $tree_access_cacheability->applyTo($build);
        return $build;
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.