LocalTaskManagerInterface.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. namespace Drupal\Core\Menu;
  3. use Drupal\Component\Plugin\PluginManagerInterface;
  4. use Drupal\Core\Cache\RefinableCacheableDependencyInterface;
  5. /**
  6. * Manages discovery and instantiation of menu local task plugins.
  7. *
  8. * This manager finds plugins that are rendered as local tasks (usually tabs).
  9. * Derivatives are supported for modules that wish to generate multiple tabs on
  10. * behalf of something else.
  11. */
  12. interface LocalTaskManagerInterface extends PluginManagerInterface {
  13. /**
  14. * Gets the title for a local task.
  15. *
  16. * @param \Drupal\Core\Menu\LocalTaskInterface $local_task
  17. * A local task plugin instance to get the title for.
  18. *
  19. * @return string
  20. * The localized title.
  21. */
  22. public function getTitle(LocalTaskInterface $local_task);
  23. /**
  24. * Find all local tasks that appear on a named route.
  25. *
  26. * @param string $route_name
  27. * The route for which to find local tasks.
  28. *
  29. * @return array
  30. * Returns an array of task levels. Each task level contains instances
  31. * of local tasks (LocalTaskInterface) which appear on the tab route.
  32. * The array keys are the depths and the values are arrays of plugin
  33. * instances.
  34. */
  35. public function getLocalTasksForRoute($route_name);
  36. /**
  37. * Gets the render array for all local tasks.
  38. *
  39. * @param string $current_route_name
  40. * The route for which to make renderable local tasks.
  41. * @param \Drupal\Core\Cache\RefinableCacheableDependencyInterface $cacheability
  42. * The cacheability metadata for the local tasks.
  43. *
  44. * @return array
  45. * A render array as expected by menu-local-tasks.html.twig.
  46. */
  47. public function getTasksBuild($current_route_name, RefinableCacheableDependencyInterface &$cacheability);
  48. /**
  49. * Renders the local tasks (tabs) for the given route.
  50. *
  51. * @param string $route_name
  52. * The route for which to make renderable local tasks.
  53. * @param int $level
  54. * The level of tasks you ask for. Primary tasks are 0, secondary are 1.
  55. *
  56. * @return array
  57. * An array containing
  58. * - tabs: Local tasks render array for the requested level.
  59. * - route_name: The route name for the current page used to collect the
  60. * local tasks.
  61. *
  62. * @see hook_menu_local_tasks_alter()
  63. */
  64. public function getLocalTasks($route_name, $level = 0);
  65. }