1
0

INavigationManager.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. * Manages the ownCloud navigation
  12. * @since 6.0.0
  13. *
  14. * @psalm-type NavigationEntry = array{id: string, order: int, href: string, name: string, app?: string, icon?: string, classes?: string, type?: string}
  15. */
  16. interface INavigationManager {
  17. /**
  18. * Navigation entries of the app navigation
  19. * @since 16.0.0
  20. */
  21. public const TYPE_APPS = 'link';
  22. /**
  23. * Navigation entries of the settings navigation
  24. * @since 16.0.0
  25. */
  26. public const TYPE_SETTINGS = 'settings';
  27. /**
  28. * Navigation entries for public page footer navigation
  29. * @since 16.0.0
  30. */
  31. public const TYPE_GUEST = 'guest';
  32. /**
  33. * Creates a new navigation entry
  34. *
  35. * @param array array|\Closure $entry Array containing: id, name, order, icon and href key
  36. * If a menu entry (type = 'link') is added, you shall also set app to the app that added the entry.
  37. * The use of a closure is preferred, because it will avoid
  38. * loading the routing of your app, unless required.
  39. * @psalm-param NavigationEntry|callable():NavigationEntry $entry
  40. * @return void
  41. * @since 6.0.0
  42. */
  43. public function add($entry);
  44. /**
  45. * Sets the current navigation entry of the currently running app
  46. * @param string $appId id of the app entry to activate (from added $entry)
  47. * @return void
  48. * @since 6.0.0
  49. */
  50. public function setActiveEntry($appId);
  51. /**
  52. * Get the current navigation entry of the currently running app
  53. * @return string
  54. * @since 20.0.0
  55. */
  56. public function getActiveEntry();
  57. /**
  58. * Get a list of navigation entries
  59. *
  60. * @param string $type type of the navigation entries
  61. * @return array
  62. * @since 14.0.0
  63. */
  64. public function getAll(string $type = self::TYPE_APPS): array;
  65. /**
  66. * Set an unread counter for navigation entries
  67. *
  68. * @param string $id id of the navigation entry
  69. * @param int $unreadCounter Number of unread entries (0 to hide the counter which is the default)
  70. * @since 22.0.0
  71. */
  72. public function setUnreadCounter(string $id, int $unreadCounter): void;
  73. }