3 namespace Drupal\Core\Menu;
5 use Drupal\Core\Cache\CacheableMetadata;
8 * Defines an interface for menu selector form elements and menu link options.
10 interface MenuParentFormSelectorInterface {
13 * Gets the options for a select element to choose a menu and parent.
16 * Optional ID of a link plugin. This will exclude the link and its
17 * children from the select options.
19 * Optional array of menu names as keys and titles as values to limit
20 * the select options. If NULL, all menus will be included.
21 * @param \Drupal\Core\Cache\CacheableMetadata|null &$cacheability
22 * Optional cacheability metadata object, which will be populated based on
23 * the accessibility of the links and the cacheability of the links.
26 * Keyed array where the keys are contain a menu name and parent ID and
27 * the values are a menu name or link title indented by depth.
29 public function getParentSelectOptions($id = '', array $menus = NULL, CacheableMetadata &$cacheability = NULL);
32 * Gets a form element to choose a menu and parent.
34 * The specific type of form element will vary depending on the
35 * implementation, but callers will normally need to set the #title for the
38 * @param string $menu_parent
39 * A menu name and parent ID concatenated with a ':' character to use as the
42 * (optional) ID of a link plugin. This will exclude the link and its
43 * children from being selected.
45 * (optional) array of menu names as keys and titles as values to limit
46 * the values that may be selected. If NULL, all menus will be included.
49 * A form element to choose a parent, or an empty array if no possible
50 * parents exist for the given parameters. The resulting form value will be
51 * a single string containing the chosen menu name and parent ID separated
54 public function parentSelectElement($menu_parent, $id = '', array $menus = NULL);