annotate core/lib/Drupal/Core/Menu/MenuLinkInterface.php @ 19:fa3358dc1485 tip

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