MenuParentFormSelectorInterface.php 2.1 KB

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