PageRenderTime 47ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 1ms

/core/lib/Drupal/Core/Menu/MenuLinkInterface.php

http://github.com/drupal/drupal
PHP | 231 lines | 29 code | 26 blank | 176 comment | 0 complexity | f801b4ab8c126b3cd94f7e78f77124de MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1
  1. <?php
  2. namespace Drupal\Core\Menu;
  3. use Drupal\Component\Plugin\PluginInspectionInterface;
  4. use Drupal\Component\Plugin\DerivativeInspectionInterface;
  5. use Drupal\Core\Cache\CacheableDependencyInterface;
  6. /**
  7. * Defines an interface for classes providing a type of menu link.
  8. */
  9. interface MenuLinkInterface extends PluginInspectionInterface, DerivativeInspectionInterface, CacheableDependencyInterface {
  10. /**
  11. * Returns the weight of the menu link.
  12. *
  13. * @return int
  14. * The weight of the menu link, 0 by default.
  15. */
  16. public function getWeight();
  17. /**
  18. * Returns the localized title to be shown for this link.
  19. *
  20. * @return string
  21. * The title of the menu link.
  22. */
  23. public function getTitle();
  24. /**
  25. * Returns the description of the menu link.
  26. *
  27. * @return string
  28. * The description of the menu link.
  29. */
  30. public function getDescription();
  31. /**
  32. * Returns the menu name of the menu link.
  33. *
  34. * @return string
  35. * The menu name of the menu link.
  36. */
  37. public function getMenuName();
  38. /**
  39. * Returns the provider (module name) of the menu link.
  40. *
  41. * @return string
  42. * The provider of the menu link.
  43. */
  44. public function getProvider();
  45. /**
  46. * Returns the plugin ID of the menu link's parent, or an empty string.
  47. *
  48. * @return string
  49. * The parent plugin ID.
  50. */
  51. public function getParent();
  52. /**
  53. * Returns whether the menu link is enabled (not hidden).
  54. *
  55. * @return bool
  56. * TRUE for enabled, FALSE otherwise.
  57. */
  58. public function isEnabled();
  59. /**
  60. * Returns whether the child menu links should always been shown.
  61. *
  62. * @return bool
  63. * TRUE for expanded, FALSE otherwise.
  64. */
  65. public function isExpanded();
  66. /**
  67. * Returns whether this link can be reset.
  68. *
  69. * In general, only links that store overrides using the
  70. * menu_link.static.overrides service should return TRUE for this method.
  71. *
  72. * @return bool
  73. * TRUE if it can be reset, FALSE otherwise.
  74. */
  75. public function isResettable();
  76. /**
  77. * Returns whether this link can be translated.
  78. *
  79. * @return bool
  80. * TRUE if the link can be translated, FALSE otherwise.
  81. */
  82. public function isTranslatable();
  83. /**
  84. * Returns whether this link can be deleted.
  85. *
  86. * @return bool
  87. * TRUE if the link can be deleted, FALSE otherwise.
  88. */
  89. public function isDeletable();
  90. /**
  91. * Returns the route name, if available.
  92. *
  93. * @return string
  94. * The name of the route this menu link links to.
  95. */
  96. public function getRouteName();
  97. /**
  98. * Returns the route parameters, if available.
  99. *
  100. * @return array
  101. * An array of parameter names and values.
  102. */
  103. public function getRouteParameters();
  104. /**
  105. * Returns a URL object containing either the external path or route.
  106. *
  107. * @param bool $title_attribute
  108. * (optional) If TRUE, add the link description as the title attribute if
  109. * the description is not empty.
  110. *
  111. * @return \Drupal\Core\Url
  112. * A URL object containing either the external path or route.
  113. */
  114. public function getUrlObject($title_attribute = TRUE);
  115. /**
  116. * Returns the options for this link.
  117. *
  118. * @return array
  119. * An associative array of options.
  120. */
  121. public function getOptions();
  122. /**
  123. * Returns any metadata for this link.
  124. *
  125. * @return array
  126. * The metadata for the menu link.
  127. */
  128. public function getMetaData();
  129. /**
  130. * Updates the definition values for a menu link.
  131. *
  132. * Depending on the implementation details of the class, not all definition
  133. * values may be changed. For example, changes to the title of a static link
  134. * will be discarded.
  135. *
  136. * In general, this method should not be called directly, but will be called
  137. * automatically from MenuLinkManagerInterface::updateDefinition().
  138. *
  139. * @param array $new_definition_values
  140. * The new values for the link definition. This will usually be just a
  141. * subset of the plugin definition.
  142. * @param bool $persist
  143. * TRUE to have the link persist the changed values to any additional
  144. * storage.
  145. *
  146. * @return array
  147. * The plugin definition incorporating any allowed changes.
  148. */
  149. public function updateLink(array $new_definition_values, $persist);
  150. /**
  151. * Deletes a menu link.
  152. *
  153. * In general, this method should not be called directly, but will be called
  154. * automatically from MenuLinkManagerInterface::removeDefinition().
  155. *
  156. * This method will only delete the link from any additional storage, but not
  157. * from the plugin.manager.menu.link service.
  158. *
  159. * @throws \Drupal\Component\Plugin\Exception\PluginException
  160. * If the link is not deletable.
  161. */
  162. public function deleteLink();
  163. /**
  164. * Returns the name of a class that can build an editing form for this link.
  165. *
  166. * To instantiate the form class, use an instance of the
  167. * \Drupal\Core\DependencyInjection\ClassResolverInterface, such as from the
  168. * class_resolver service. Then call the setMenuLinkInstance() method on the
  169. * form instance with the menu link plugin instance.
  170. *
  171. * @todo Add a code example. https://www.drupal.org/node/2302849
  172. *
  173. * @return string
  174. * A class that implements \Drupal\Core\Menu\Form\MenuLinkFormInterface.
  175. */
  176. public function getFormClass();
  177. /**
  178. * Returns route information for a route to delete the menu link.
  179. *
  180. * @return \Drupal\Core\Url|null
  181. * A Url object, or NULL if there is no route (e.g. when the link is not
  182. * deletable).
  183. */
  184. public function getDeleteRoute();
  185. /**
  186. * Returns route information for a custom edit form for the menu link.
  187. *
  188. * Plugins should return a value here if they have a special edit form, or if
  189. * they need to define additional local tasks, local actions, etc. that are
  190. * visible from the edit form.
  191. *
  192. * @return \Drupal\Core\Url|null
  193. * A Url object, or NULL if there is no route because there is no custom
  194. * edit route for this instance.
  195. */
  196. public function getEditRoute();
  197. /**
  198. * Returns route information for a route to translate the menu link.
  199. *
  200. * @return \Drupal\Core\Url|null
  201. * A Url object, or NULL if there is no route (e.g. when the link is not
  202. * translatable).
  203. */
  204. public function getTranslateRoute();
  205. }