INavigationManager.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
  5. * SPDX-License-Identifier: AGPL-3.0-only
  6. */
  7. // use OCP namespace for all classes that are considered public.
  8. // This means that they should be used by apps instead of the internal Nextcloud classes
  9. namespace OCP;
  10. /**
  11. * @psalm-type NavigationEntry = array{id: string, order: int, href: string, name: string, app?: string, icon?: string, classes?: string, type?: string}
  12. */
  13. /**
  14. * Manages the ownCloud navigation
  15. * @since 6.0.0
  16. */
  17. interface INavigationManager {
  18. /**
  19. * Navigation entries of the app navigation
  20. * @since 16.0.0
  21. */
  22. public const TYPE_APPS = 'link';
  23. /**
  24. * Navigation entries of the settings navigation
  25. * @since 16.0.0
  26. */
  27. public const TYPE_SETTINGS = 'settings';
  28. /**
  29. * Navigation entries for public page footer navigation
  30. * @since 16.0.0
  31. */
  32. public const TYPE_GUEST = 'guest';
  33. /**
  34. * Creates a new navigation entry
  35. *
  36. * @param array array|\Closure $entry Array containing: id, name, order, icon and href key
  37. * If a menu entry (type = 'link') is added, you shall also set app to the app that added the entry.
  38. * The use of a closure is preferred, because it will avoid
  39. * loading the routing of your app, unless required.
  40. * @psalm-param NavigationEntry|callable():NavigationEntry $entry
  41. * @return void
  42. * @since 6.0.0
  43. */
  44. public function add($entry);
  45. /**
  46. * Sets the current navigation entry of the currently running app
  47. * @param string $appId id of the app entry to activate (from added $entry)
  48. * @return void
  49. * @since 6.0.0
  50. */
  51. public function setActiveEntry($appId);
  52. /**
  53. * Get the current navigation entry of the currently running app
  54. * @return string
  55. * @since 20.0.0
  56. */
  57. public function getActiveEntry();
  58. /**
  59. * Get a list of navigation entries
  60. *
  61. * @param string $type type of the navigation entries
  62. * @return array
  63. * @since 14.0.0
  64. */
  65. public function getAll(string $type = self::TYPE_APPS): array;
  66. /**
  67. * Set an unread counter for navigation entries
  68. *
  69. * @param string $id id of the navigation entry
  70. * @param int $unreadCounter Number of unread entries (0 to hide the counter which is the default)
  71. * @since 22.0.0
  72. */
  73. public function setUnreadCounter(string $id, int $unreadCounter): void;
  74. }