MenuParentFormSelector
class MenuParentFormSelector implements MenuParentFormSelectorInterface (View source)
Default implementation of the menu parent form selector service.
The form selector is a list of all appropriate menu links.
Traits
Wrapper methods for \Drupal\Core\StringTranslation\TranslationInterface.
Properties
| protected TranslationInterface | $stringTranslation | The string translation service. |
from StringTranslationTrait |
| protected MenuLinkTreeInterface | $menuLinkTree | The menu link tree service. |
|
| protected EntityTypeManagerInterface | $entityTypeManager | The entity type manager service. |
Methods
Translates a string to the current language or to a given language.
Formats a string containing a count of items.
Returns the number of plurals supported by a given language.
Gets the string translation service.
Constructs a \Drupal\Core\Menu\MenuParentFormSelector.
Gets the options for a select element to choose a menu and parent.
Gets a form element to choose a menu and parent.
Returns the maximum depth of the possible parents of the menu link.
Iterates over all items in the tree to prepare the parents select options.
Gets a list of menu names for use as options.
Details
protected TranslatableMarkup
t(string $string, array $args = [], array $options = [])
Translates a string to the current language or to a given language.
See \Drupal\Core\StringTranslation\TranslatableMarkup::__construct() for important security information and usage guidelines.
In order for strings to be localized, make them available in one of the ways supported by the
protected
formatPlural($count, $singular, $plural, array $args = [], array $options = [])
Formats a string containing a count of items.
protected
getNumberOfPlurals($langcode = NULL)
Returns the number of plurals supported by a given language.
protected TranslationInterface
getStringTranslation()
Gets the string translation service.
$this
setStringTranslation(TranslationInterface $translation)
Sets the string translation service to use.
__construct(MenuLinkTreeInterface $menu_link_tree, EntityTypeManagerInterface $entity_type_manager, TranslationInterface $string_translation)
Constructs a \Drupal\Core\Menu\MenuParentFormSelector.
array
getParentSelectOptions(string $id = '', array $menus = NULL, CacheableMetadata $cacheability = NULL)
Gets the options for a select element to choose a menu and parent.
array
parentSelectElement(string $menu_parent, string $id = '', array $menus = NULL)
Gets a form element to choose a menu and parent.
The specific type of form element will vary depending on the implementation, but callers will normally need to set the #title for the element.
protected int
getParentDepthLimit(string $id)
Returns the maximum depth of the possible parents of the menu link.
protected
parentSelectOptionsTreeWalk(array $tree, string $menu_name, string $indent, array $options, string $exclude, int $depth_limit, CacheableMetadata $cacheability = NULL)
Iterates over all items in the tree to prepare the parents select options.
protected array
getMenuOptions(array $menu_names = NULL)
Gets a list of menu names for use as options.