LocalTaskInterface.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. namespace Drupal\Core\Menu;
  3. use Drupal\Core\Routing\RouteMatchInterface;
  4. /**
  5. * Defines an interface for menu local tasks.
  6. *
  7. * Menu local tasks are typically rendered as navigation tabs above the content
  8. * region, though other presentations are possible. It is convention that the
  9. * titles of these tasks should be short verbs if possible.
  10. *
  11. * @see \Drupal\Core\Menu\LocalTaskManagerInterface
  12. */
  13. interface LocalTaskInterface {
  14. /**
  15. * Get the route name from the settings.
  16. *
  17. * @return string
  18. * The name of the route this local task links to.
  19. */
  20. public function getRouteName();
  21. /**
  22. * Returns the localized title to be shown for this tab.
  23. *
  24. * Subclasses may add optional arguments like NodeInterface $node = NULL that
  25. * will be supplied by the ControllerResolver.
  26. *
  27. * @return string
  28. * The title of the local task.
  29. */
  30. public function getTitle();
  31. /**
  32. * Returns the route parameters needed to render a link for the local task.
  33. *
  34. * @param \Drupal\Core\Routing\RouteMatchInterface $route_match
  35. * The current route match.
  36. *
  37. * @return array
  38. * An array of parameter names and values.
  39. */
  40. public function getRouteParameters(RouteMatchInterface $route_match);
  41. /**
  42. * Returns the weight of the local task.
  43. *
  44. * @return int|null
  45. * The weight of the task or NULL.
  46. */
  47. public function getWeight();
  48. /**
  49. * Returns options for rendering a link to the local task.
  50. *
  51. * @param \Drupal\Core\Routing\RouteMatchInterface $route_match
  52. * The current route match.
  53. *
  54. * @return array
  55. * An associative array of options.
  56. */
  57. public function getOptions(RouteMatchInterface $route_match);
  58. /**
  59. * Sets the active status.
  60. *
  61. * @param bool $active
  62. * Sets whether this tab is active (e.g. a parent of the current tab).
  63. *
  64. * @return \Drupal\Core\Menu\LocalTaskInterface
  65. * The called object for chaining.
  66. */
  67. public function setActive($active = TRUE);
  68. /**
  69. * Gets the active status.
  70. *
  71. * @return bool
  72. * TRUE if the local task is active, FALSE otherwise.
  73. *
  74. * @see \Drupal\system\Plugin\MenuLocalTaskInterface::setActive()
  75. */
  76. public function getActive();
  77. }