function MenuParentFormSelector::getParentSelectOptions
Same name in other branches
- 9 core/lib/Drupal/Core/Menu/MenuParentFormSelector.php \Drupal\Core\Menu\MenuParentFormSelector::getParentSelectOptions()
- 8.9.x core/lib/Drupal/Core/Menu/MenuParentFormSelector.php \Drupal\Core\Menu\MenuParentFormSelector::getParentSelectOptions()
- 10 core/lib/Drupal/Core/Menu/MenuParentFormSelector.php \Drupal\Core\Menu\MenuParentFormSelector::getParentSelectOptions()
Overrides MenuParentFormSelectorInterface::getParentSelectOptions
1 call to MenuParentFormSelector::getParentSelectOptions()
- MenuParentFormSelector::parentSelectElement in core/
lib/ Drupal/ Core/ Menu/ MenuParentFormSelector.php - Gets a form element to choose a menu and parent.
File
-
core/
lib/ Drupal/ Core/ Menu/ MenuParentFormSelector.php, line 52
Class
- MenuParentFormSelector
- Default implementation of the menu parent form selector service.
Namespace
Drupal\Core\MenuCode
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.