function MenuParentFormSelector::getParentSelectOptions

Same name in other branches
  1. 9 core/lib/Drupal/Core/Menu/MenuParentFormSelector.php \Drupal\Core\Menu\MenuParentFormSelector::getParentSelectOptions()
  2. 8.9.x core/lib/Drupal/Core/Menu/MenuParentFormSelector.php \Drupal\Core\Menu\MenuParentFormSelector::getParentSelectOptions()
  3. 11.x core/lib/Drupal/Core/Menu/MenuParentFormSelector.php \Drupal\Core\Menu\MenuParentFormSelector::getParentSelectOptions()
1 call to MenuParentFormSelector::getParentSelectOptions()
MenuParentFormSelector::parentSelectElement in core/lib/Drupal/Core/Menu/MenuParentFormSelector.php

File

core/lib/Drupal/Core/Menu/MenuParentFormSelector.php, line 52

Class

MenuParentFormSelector
Default implementation of the menu parent form selector service.

Namespace

Drupal\Core\Menu

Code

public function getParentSelectOptions($id = '', ?array $menus = NULL, ?CacheableMetadata &$cacheability = NULL) {
    if (!isset($menus)) {
        $menus = $this->getMenuOptions();
    }
    $options = [];
    $depth_limit = $this->getParentDepthLimit($id);
    foreach ($menus as $menu_name => $menu_title) {
        $options[$menu_name . ':'] = '<' . $menu_title . '>';
        $parameters = new MenuTreeParameters();
        $parameters->setMaxDepth($depth_limit);
        $tree = $this->menuLinkTree
            ->load($menu_name, $parameters);
        $manipulators = [
            [
                'callable' => 'menu.default_tree_manipulators:checkNodeAccess',
            ],
            [
                'callable' => 'menu.default_tree_manipulators:checkAccess',
            ],
            [
                'callable' => 'menu.default_tree_manipulators:generateIndexAndSort',
            ],
        ];
        $tree = $this->menuLinkTree
            ->transform($tree, $manipulators);
        $this->parentSelectOptionsTreeWalk($tree, $menu_name, '--', $options, $id, $depth_limit, $cacheability);
    }
    return $options;
}

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