ContextualLinkInterface.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. namespace Drupal\Core\Menu;
  3. /**
  4. * Defines a contextual link plugin.
  5. *
  6. * Contextual links by default are in the module_name.links.contextual.yml
  7. * file. These YAML files contain a list of contextual link plugin definitions,
  8. * keyed by the plugin ID. Each definition must define a route_name and a group
  9. * and might define title, options, and weight. See the getter methods on this
  10. * interface for an explanation of each.
  11. *
  12. * @ingroup menu
  13. */
  14. interface ContextualLinkInterface {
  15. /**
  16. * Returns the localized title to be shown for this contextual link.
  17. *
  18. * Subclasses may add optional arguments like NodeInterface $node = NULL that
  19. * will be supplied by the ControllerResolver.
  20. *
  21. * @return string
  22. * The title to be shown for this action.
  23. *
  24. * @see \Drupal\Core\Menu\ContextualLinksManager::getTitle()
  25. */
  26. public function getTitle();
  27. /**
  28. * Returns the route name of the contextual link.
  29. *
  30. * @return string
  31. * The name of the route this contextual link links to.
  32. */
  33. public function getRouteName();
  34. /**
  35. * Returns the group this contextual link should be rendered in.
  36. *
  37. * A contextual link group is a set of contextual links that are displayed
  38. * together on a certain page. For example, the 'block' group displays all
  39. * links related to the block, such as the block instance edit link as well as
  40. * the views edit link, if it is a view block.
  41. *
  42. * @return string
  43. * The contextual links group name.
  44. */
  45. public function getGroup();
  46. /**
  47. * Returns the link options passed to the link generator.
  48. *
  49. * @return array
  50. * An associative array of options.
  51. */
  52. public function getOptions();
  53. /**
  54. * Returns the weight of the contextual link.
  55. *
  56. * The contextual links in one group are sorted by weight for display.
  57. *
  58. * @return int
  59. * The weight as positive/negative integer.
  60. */
  61. public function getWeight();
  62. }