INavigationManager.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Bart Visscher <bartv@thisnet.nl>
  6. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  7. * @author Joas Schilling <coding@schilljs.com>
  8. * @author John Molakvoæ <skjnldsv@protonmail.com>
  9. * @author Jörn Friedrich Dreyer <jfd@butonic.de>
  10. * @author Julius Härtl <jus@bitgrid.net>
  11. * @author Morris Jobke <hey@morrisjobke.de>
  12. * @author Roeland Jago Douma <roeland@famdouma.nl>
  13. * @author Thomas Müller <thomas.mueller@tmit.eu>
  14. *
  15. * @license AGPL-3.0
  16. *
  17. * This code is free software: you can redistribute it and/or modify
  18. * it under the terms of the GNU Affero General Public License, version 3,
  19. * as published by the Free Software Foundation.
  20. *
  21. * This program is distributed in the hope that it will be useful,
  22. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  23. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  24. * GNU Affero General Public License for more details.
  25. *
  26. * You should have received a copy of the GNU Affero General Public License, version 3,
  27. * along with this program. If not, see <http://www.gnu.org/licenses/>
  28. *
  29. */
  30. // use OCP namespace for all classes that are considered public.
  31. // This means that they should be used by apps instead of the internal ownCloud classes
  32. namespace OCP;
  33. /**
  34. * Manages the ownCloud navigation
  35. * @since 6.0.0
  36. *
  37. * @psalm-type NavigationEntry = array{id: string, order: int, href: string, name: string, app?: string, icon?: string, classes?: string, type?: string}
  38. */
  39. interface INavigationManager {
  40. /**
  41. * Navigation entries of the app navigation
  42. * @since 16.0.0
  43. */
  44. public const TYPE_APPS = 'link';
  45. /**
  46. * Navigation entries of the settings navigation
  47. * @since 16.0.0
  48. */
  49. public const TYPE_SETTINGS = 'settings';
  50. /**
  51. * Navigation entries for public page footer navigation
  52. * @since 16.0.0
  53. */
  54. public const TYPE_GUEST = 'guest';
  55. /**
  56. * Creates a new navigation entry
  57. *
  58. * @param array array|\Closure $entry Array containing: id, name, order, icon and href key
  59. * If a menu entry (type = 'link') is added, you shall also set app to the app that added the entry.
  60. * The use of a closure is preferred, because it will avoid
  61. * loading the routing of your app, unless required.
  62. * @psalm-param NavigationEntry|callable():NavigationEntry $entry
  63. * @return void
  64. * @since 6.0.0
  65. */
  66. public function add($entry);
  67. /**
  68. * Sets the current navigation entry of the currently running app
  69. * @param string $appId id of the app entry to activate (from added $entry)
  70. * @return void
  71. * @since 6.0.0
  72. */
  73. public function setActiveEntry($appId);
  74. /**
  75. * Get the current navigation entry of the currently running app
  76. * @return string
  77. * @since 20.0.0
  78. */
  79. public function getActiveEntry();
  80. /**
  81. * Get a list of navigation entries
  82. *
  83. * @param string $type type of the navigation entries
  84. * @return array
  85. * @since 14.0.0
  86. */
  87. public function getAll(string $type = self::TYPE_APPS): array;
  88. /**
  89. * Set an unread counter for navigation entries
  90. *
  91. * @param string $id id of the navigation entry
  92. * @param int $unreadCounter Number of unread entries (0 to hide the counter which is the default)
  93. * @since 22.0.0
  94. */
  95. public function setUnreadCounter(string $id, int $unreadCounter): void;
  96. }