MenuTreeStorageInterface
interface MenuTreeStorageInterface (View source)
Defines an interface for storing a menu tree containing menu link IDs.
The tree contains a hierarchy of menu links which have an ID as well as a route name or external URL.
Methods
The maximum depth of tree the storage implementation supports.
Clears all definitions cached in memory.
Rebuilds the stored menu link definitions.
Loads a menu link plugin definition from the storage.
Loads multiple plugin definitions from the storage.
Loads multiple plugin definitions from the storage based on properties.
Loads multiple plugin definitions from the storage based on route.
Saves a plugin definition to the storage.
Deletes a menu link definition from the storage.
Loads a menu link tree from the storage.
Loads all the enabled menu links that are below the given ID.
Loads all the IDs for menu links that are below the given ID.
Loads a subtree rooted by the given ID.
Returns all the IDs that represent the path to the root of the tree.
Finds expanded links in a menu given a set of possible parents.
Finds the height of a subtree rooted by the given ID.
Determines whether a specific menu name is used in the tree.
Returns the used menu names in the tree storage.
Counts the total number of menu links in one menu or all menus.
Details
int
maxDepth()
The maximum depth of tree the storage implementation supports.
resetDefinitions()
Clears all definitions cached in memory.
rebuild(array $definitions)
Rebuilds the stored menu link definitions.
Links that saved by passing definitions into this method must be included on all future calls, or they will be purged. This allows for automatic cleanup e.g. when modules are uninstalled.
array|false
load(string $id)
Loads a menu link plugin definition from the storage.
array
loadMultiple(array $ids)
Loads multiple plugin definitions from the storage.
array
loadByProperties(array $properties)
Loads multiple plugin definitions from the storage based on properties.
array
loadByRoute(string $route_name, array $route_parameters = [], string $menu_name = NULL)
Loads multiple plugin definitions from the storage based on route.
array
save(array $definition)
Saves a plugin definition to the storage.
delete(string $id)
Deletes a menu link definition from the storage.
array
loadTreeData(string $menu_name, MenuTreeParameters $parameters)
Loads a menu link tree from the storage.
This function may be used build the data for a menu tree only, for example to further massage the data manually before further processing happens. MenuLinkTree::checkAccess() needs to be invoked afterwards.
The tree order is maintained using an optimized algorithm, for example by storing each parent in an individual field, see https://www.drupal.org/node/141866 for more details. However, any details of the storage should not be relied upon since it may be swapped with a different implementation.
array
loadAllChildren(string $id, int $max_relative_depth = NULL)
Loads all the enabled menu links that are below the given ID.
The returned links are not ordered, and visible children will be included even if they have parent that is not enabled or ancestor so would not normally appear in a rendered tree.
array
getAllChildIds(string $id)
Loads all the IDs for menu links that are below the given ID.
array
loadSubtreeData(string $id, int $max_relative_depth = NULL)
Loads a subtree rooted by the given ID.
The returned links are structured like those from loadTreeData().
array
getRootPathIds(string $id)
Returns all the IDs that represent the path to the root of the tree.
array
getExpanded(string $menu_name, array $parents)
Finds expanded links in a menu given a set of possible parents.
int
getSubtreeHeight(string $id)
Finds the height of a subtree rooted by the given ID.
bool
menuNameInUse(string $menu_name)
Determines whether a specific menu name is used in the tree.
array
getMenuNames()
Returns the used menu names in the tree storage.
int
countMenuLinks(string $menu_name = NULL)
Counts the total number of menu links in one menu or all menus.