public MenuParentFormSelector::getParentSelectOptions($id = '', array $menus = NULL, CacheableMetadata &$cacheability = NULL)
Gets the options for a select element to choose a menu and parent.
string $id: Optional ID of a link plugin. This will exclude the link and its children from the select options.
array $menus: Optional array of menu names as keys and titles as values to limit the select options. If NULL, all menus will be included.
\Drupal\Core\Cache\CacheableMetadata|NULL &$cacheability: Optional cacheability metadata object, which will be populated based on the accessibility of the links and the cacheability of the links.
array Keyed array where the keys are contain a menu name and parent ID and the values are a menu name or link title indented by depth.
Overrides MenuParentFormSelectorInterface::getParentSelectOptions
public function getParentSelectOptions($id = '', array $menus = NULL, CacheableMetadata &$cacheability = NULL) { if (!isset($menus)) { $menus = $this->getMenuOptions(); } $options = array(); $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 = array( array('callable' => 'menu.default_tree_manipulators:checkNodeAccess'), array('callable' => 'menu.default_tree_manipulators:checkAccess'), array('callable' => 'menu.default_tree_manipulators:generateIndexAndSort'), ); $tree = $this->menuLinkTree->transform($tree, $manipulators); $this->parentSelectOptionsTreeWalk($tree, $menu_name, '--', $options, $id, $depth_limit, $cacheability); } return $options; }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Menu!MenuParentFormSelector.php/function/MenuParentFormSelector::getParentSelectOptions/8.1.x