Drupal 8  8.0.2
MenuParentFormSelector Class Reference
Inheritance diagram for MenuParentFormSelector:

Public Member Functions

 __construct (MenuLinkTreeInterface $menu_link_tree, EntityManagerInterface $entity_manager, TranslationInterface $string_translation)
 
 getParentSelectOptions ($id= '', array $menus=NULL, CacheableMetadata &$cacheability=NULL)
 
 parentSelectElement ($menu_parent, $id= '', array $menus=NULL)
 

Protected Member Functions

 getParentDepthLimit ($id)
 
 parentSelectOptionsTreeWalk (array $tree, $menu_name, $indent, array &$options, $exclude, $depth_limit, CacheableMetadata &$cacheability=NULL)
 

Protected Attributes

 $menuLinkTree
 
 $entityManager
 

Detailed Description

Default implementation of the menu parent form selector service.

The form selector is a list of all appropriate menu links.

Constructor & Destructor Documentation

__construct ( MenuLinkTreeInterface  $menu_link_tree,
EntityManagerInterface  $entity_manager,
TranslationInterface  $string_translation 
)

Constructs a

Parameters
\Drupal\Core\Menu\MenuLinkTreeInterface$menu_link_treeThe menu link tree service.
\Drupal\Core\Entity\EntityManagerInterface$entity_managerThe entity manager.
\Drupal\Core\StringTranslation\TranslationInterface$string_translationThe string translation service.

References Drupal\entityManager().

Here is the call graph for this function:

Member Function Documentation

getParentDepthLimit (   $id)
protected

Returns the maximum depth of the possible parents of the menu link.

Parameters
string$idThe menu link plugin ID or an empty value for a new link.
Returns
int The depth related to the depth of the given menu link.

Referenced by MenuParentFormSelector\getParentSelectOptions().

Here is the caller graph for this function:

getParentSelectOptions (   $id = '',
array  $menus = NULL,
CacheableMetadata $cacheability = NULL 
)

{Gets the options for a select element to choose a menu and parent.

Parameters
string$idOptional ID of a link plugin. This will exclude the link and its children from the select options.
array$menusOptional 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&$cacheabilityOptional cacheability metadata object, which will be populated based on the accessibility of the links and the cacheability of the links.
Returns
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.
}

Implements MenuParentFormSelectorInterface.

References MenuParentFormSelector\getParentDepthLimit(), and MenuParentFormSelector\parentSelectOptionsTreeWalk().

Referenced by MenuParentFormSelector\parentSelectElement().

Here is the call graph for this function:

Here is the caller graph for this function:

parentSelectElement (   $menu_parent,
  $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.

Parameters
string$menu_parentA menu name and parent ID concatenated with a ':' character to use as the default value.
string$id(optional) ID of a link plugin. This will exclude the link and its children from being selected.
array$menus(optional) array of menu names as keys and titles as values to limit the values that may be selected. If NULL, all menus will be included.
Returns
array A form element to choose a parent, or an empty array if no possible parents exist for the given parameters. The resulting form value will be a single string containing the chosen menu name and parent ID separated by a ':' character.
}

Implements MenuParentFormSelectorInterface.

References MenuParentFormSelector\getParentSelectOptions().

Here is the call graph for this function:

parentSelectOptionsTreeWalk ( array  $tree,
  $menu_name,
  $indent,
array &  $options,
  $exclude,
  $depth_limit,
CacheableMetadata $cacheability = NULL 
)
protected

Iterates over all items in the tree to prepare the parents select options.

Parameters
\Drupal\Core\Menu\MenuLinkTreeElement[]$tree The menu tree.
string$menu_nameThe menu name.
string$indentThe indentation string used for the label.
array$optionsThe select options.
string$excludeAn excluded menu link.
int$depth_limitThe maximum depth of menu links considered for the select options.
\Drupal\Core\Cache\CacheableMetadata | NULL&$cacheabilityThe object to add cacheability metadata to, if not NULL.

References CacheableMetadata\createFromObject(), t(), and Unicode\truncate().

Referenced by MenuParentFormSelector\getParentSelectOptions().

Here is the call graph for this function:

Here is the caller graph for this function:


The documentation for this class was generated from the following file: