MenuLinkInterface
interface MenuLinkInterface implements PluginInspectionInterface, DerivativeInspectionInterface, CacheableDependencyInterface (View source)
Defines an interface for classes providing a type of menu link.
Methods
Gets the definition of the plugin implementation.
Gets the base_plugin_id of the plugin instance.
Gets the derivative_id of the plugin instance.
The cache contexts associated with this object.
The cache tags associated with this object.
The maximum age for which this object may be cached.
Returns the weight of the menu link.
Returns the localized title to be shown for this link.
Returns the description of the menu link.
Returns the menu name of the menu link.
Returns the provider (module name) of the menu link.
Returns the plugin ID of the menu link's parent, or an empty string.
Returns whether the menu link is enabled (not hidden).
Returns whether the child menu links should always been shown.
Returns whether this link can be reset.
Returns whether this link can be translated.
Returns whether this link can be deleted.
Returns the route name, if available.
Returns the route parameters, if available.
Returns a URL object containing either the external path or route.
Returns the options for this link.
Returns any metadata for this link.
Updates the definition values for a menu link.
Deletes a menu link.
Returns the name of a class that can build an editing form for this link.
Returns route information for a route to delete the menu link.
Returns route information for a custom edit form for the menu link.
Returns route information for a route to translate the menu link.
Details
string
getPluginId()
Gets the plugin_id of the plugin instance.
array
getPluginDefinition()
Gets the definition of the plugin implementation.
string
getBaseId()
Gets the base_plugin_id of the plugin instance.
string|null
getDerivativeId()
Gets the derivative_id of the plugin instance.
string[]
getCacheContexts()
The cache contexts associated with this object.
These identify a specific variation/representation of the object.
Cache contexts are tokens: placeholders that are converted to cache keys by the @cache_contexts_manager service. The replacement value depends on the request context (the current URL, language, and so on). They're converted before storing an object in cache.
string[]
getCacheTags()
The cache tags associated with this object.
When this object is modified, these cache tags will be invalidated.
int
getCacheMaxAge()
The maximum age for which this object may be cached.
int
getWeight()
Returns the weight of the menu link.
string
getTitle()
Returns the localized title to be shown for this link.
string
getDescription()
Returns the description of the menu link.
string
getMenuName()
Returns the menu name of the menu link.
string
getProvider()
Returns the provider (module name) of the menu link.
string
getParent()
Returns the plugin ID of the menu link's parent, or an empty string.
bool
isEnabled()
Returns whether the menu link is enabled (not hidden).
bool
isExpanded()
Returns whether the child menu links should always been shown.
bool
isResettable()
Returns whether this link can be reset.
In general, only links that store overrides using the menu_link.static.overrides service should return TRUE for this method.
bool
isTranslatable()
Returns whether this link can be translated.
bool
isDeletable()
Returns whether this link can be deleted.
string
getRouteName()
Returns the route name, if available.
array
getRouteParameters()
Returns the route parameters, if available.
Url
getUrlObject(bool $title_attribute = TRUE)
Returns a URL object containing either the external path or route.
array
getOptions()
Returns the options for this link.
array
getMetaData()
Returns any metadata for this link.
array
updateLink(array $new_definition_values, bool $persist)
Updates the definition values for a menu link.
Depending on the implementation details of the class, not all definition values may be changed. For example, changes to the title of a static link will be discarded.
In general, this method should not be called directly, but will be called automatically from MenuLinkManagerInterface::updateDefinition().
deleteLink()
Deletes a menu link.
In general, this method should not be called directly, but will be called automatically from MenuLinkManagerInterface::removeDefinition().
This method will only delete the link from any additional storage, but not from the plugin.manager.menu.link service.
string
getFormClass()
Returns the name of a class that can build an editing form for this link.
To instantiate the form class, use an instance of the \Drupal\Core\DependencyInjection\ClassResolverInterface, such as from the class_resolver service. Then call the setMenuLinkInstance() method on the form instance with the menu link plugin instance.
Url|null
getDeleteRoute()
Returns route information for a route to delete the menu link.
Url|null
getEditRoute()
Returns route information for a custom edit form for the menu link.
Plugins should return a value here if they have a special edit form, or if they need to define additional local tasks, local actions, etc. that are visible from the edit form.
Url|null
getTranslateRoute()
Returns route information for a route to translate the menu link.