MenuLinkManagerInterface
interface MenuLinkManagerInterface implements PluginManagerInterface (View source)
Defines an interface for managing menu links and storing their definitions.
Menu link managers support both automatic plugin definition discovery and manually maintaining plugin definitions.
MenuLinkManagerInterface::updateDefinition() can be used to update a single menu link's definition and pass this onto the menu storage without requiring a full MenuLinkManagerInterface::rebuild().
Implementations that do not use automatic discovery should call MenuLinkManagerInterface::addDefinition() or MenuLinkManagerInterface::removeDefinition() when they add or remove links, and MenuLinkManagerInterface::updateDefinition() to update links they have already defined.
Methods
Gets a specific plugin definition.
Indicates if a specific plugin definition exists.
Creates a pre-configured instance of a plugin.
Gets a preconfigured instance of a plugin.
Triggers discovery, save, and cleanup of discovered links.
Deletes all links having a certain menu name.
Removes a single link definition from the menu tree storage.
Loads multiple plugin instances based on route.
Adds a new menu link definition to the menu tree storage.
Updates the values for a menu link definition in the menu tree storage.
Resets the values for a menu link based on the values found by discovery.
Counts the total number of menu links.
Loads all parent link IDs of a given menu link.
Loads all child link IDs of a given menu link, regardless of visibility.
Determines if any links use a given menu name.
Resets any local definition cache. Used for testing.
Details
mixed
getDefinition(string $plugin_id, bool $exception_on_invalid = TRUE)
Gets a specific plugin definition.
array
getDefinitions()
Gets the definition of all plugins for this type.
bool
hasDefinition(string $plugin_id)
Indicates if a specific plugin definition exists.
object
createInstance(string $plugin_id, array $configuration = [])
Creates a pre-configured instance of a plugin.
object|false
getInstance(array $options)
Gets a preconfigured instance of a plugin.
rebuild()
Triggers discovery, save, and cleanup of discovered links.
deleteLinksInMenu(string $menu_name)
Deletes all links having a certain menu name.
If a link is not deletable but is resettable, the link will be reset to have its original menu name, under the assumption that the original menu is not the one we are deleting it from. Note that when resetting, if the original menu name is the same as the menu name passed to this method, the link will not be moved or deleted.
removeDefinition(string $id, bool $persist = TRUE)
Removes a single link definition from the menu tree storage.
This is used for plugins not found through discovery to remove definitions.
MenuLinkInterface[]
loadLinksByRoute(string $route_name, array $route_parameters = [], string $menu_name = NULL)
Loads multiple plugin instances based on route.
MenuLinkInterface
addDefinition(string $id, array $definition)
Adds a new menu link definition to the menu tree storage.
Use this function when you know there is no entry in the tree. This is used for plugins not found through discovery to add new definitions.
MenuLinkInterface
updateDefinition(string $id, array $new_definition_values, bool $persist = TRUE)
Updates the values for a menu link definition in the menu tree storage.
This will update the definition for a discovered menu link without the need for a full rebuild. It is also used for plugins not found through discovery to update definitions.
MenuLinkInterface
resetLink(string $id)
Resets the values for a menu link based on the values found by discovery.
int
countMenuLinks(string $menu_name = NULL)
Counts the total number of menu links.
array
getParentIds(string $id)
Loads all parent link IDs of a given menu link.
This method is very similar to getActiveTrailIds() but allows the link to be specified rather than being discovered based on the menu name and request. This method is mostly useful for testing.
array
getChildIds(string $id)
Loads all child link IDs of a given menu link, regardless of visibility.
This method is mostly useful for testing.
bool
menuNameInUse(string $menu_name)
Determines if any links use a given menu name.
resetDefinitions()
Resets any local definition cache. Used for testing.