INavigationManager.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. * @psalm-type NavigationEntry = array{id: string, order: int, href: string, name: string, app?: string, icon?: string, classes?: string, type?: string}
  35. */
  36. /**
  37. * Manages the ownCloud navigation
  38. * @since 6.0.0
  39. */
  40. interface INavigationManager {
  41. /**
  42. * Navigation entries of the app navigation
  43. * @since 16.0.0
  44. */
  45. public const TYPE_APPS = 'link';
  46. /**
  47. * Navigation entries of the settings navigation
  48. * @since 16.0.0
  49. */
  50. public const TYPE_SETTINGS = 'settings';
  51. /**
  52. * Navigation entries for public page footer navigation
  53. * @since 16.0.0
  54. */
  55. public const TYPE_GUEST = 'guest';
  56. /**
  57. * Creates a new navigation entry
  58. *
  59. * @param array array|\Closure $entry Array containing: id, name, order, icon and href key
  60. * If a menu entry (type = 'link') is added, you shall also set app to the app that added the entry.
  61. * The use of a closure is preferred, because it will avoid
  62. * loading the routing of your app, unless required.
  63. * @psalm-param NavigationEntry|callable():NavigationEntry $entry
  64. * @return void
  65. * @since 6.0.0
  66. */
  67. public function add($entry);
  68. /**
  69. * Sets the current navigation entry of the currently running app
  70. * @param string $appId id of the app entry to activate (from added $entry)
  71. * @return void
  72. * @since 6.0.0
  73. */
  74. public function setActiveEntry($appId);
  75. /**
  76. * Get the current navigation entry of the currently running app
  77. * @return string
  78. * @since 20.0.0
  79. */
  80. public function getActiveEntry();
  81. /**
  82. * Get a list of navigation entries
  83. *
  84. * @param string $type type of the navigation entries
  85. * @return array
  86. * @since 14.0.0
  87. */
  88. public function getAll(string $type = self::TYPE_APPS): array;
  89. /**
  90. * Set an unread counter for navigation entries
  91. *
  92. * @param string $id id of the navigation entry
  93. * @param int $unreadCounter Number of unread entries (0 to hide the counter which is the default)
  94. * @since 22.0.0
  95. */
  96. public function setUnreadCounter(string $id, int $unreadCounter): void;
  97. }