2013-09-20 11:34:33 -04:00
|
|
|
<?php
|
2024-05-23 03:26:56 -04:00
|
|
|
|
2013-09-20 11:34:33 -04:00
|
|
|
/**
|
2024-05-23 03:26:56 -04:00
|
|
|
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
|
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
2013-09-20 11:34:33 -04:00
|
|
|
*/
|
2013-11-03 07:38:25 -05:00
|
|
|
// use OCP namespace for all classes that are considered public.
|
2024-05-23 03:26:56 -04:00
|
|
|
// This means that they should be used by apps instead of the internal Nextcloud classes
|
2019-11-22 14:52:10 -05:00
|
|
|
|
2013-09-20 11:34:33 -04:00
|
|
|
namespace OCP;
|
|
|
|
|
|
2025-12-17 05:15:38 -05:00
|
|
|
use OCP\AppFramework\Attribute\Consumable;
|
|
|
|
|
use OCP\AppFramework\Attribute\ExceptionalImplementable;
|
|
|
|
|
|
2013-09-20 11:34:33 -04:00
|
|
|
/**
|
2025-12-17 05:15:38 -05:00
|
|
|
* Manages the Nextcloud navigation
|
|
|
|
|
*
|
2015-04-16 11:00:08 -04:00
|
|
|
* @since 6.0.0
|
2024-05-22 10:20:34 -04:00
|
|
|
*
|
|
|
|
|
* @psalm-type NavigationEntry = array{id: string, order: int, href: string, name: string, app?: string, icon?: string, classes?: string, type?: string}
|
2025-12-17 05:15:38 -05:00
|
|
|
* @psalm-type NavigationEntryOutput = array{
|
|
|
|
|
* id: string,
|
|
|
|
|
* order?: int,
|
|
|
|
|
* href: string,
|
|
|
|
|
* icon: string,
|
|
|
|
|
* type: string,
|
|
|
|
|
* name: string,
|
|
|
|
|
* app?: string,
|
|
|
|
|
* default?: bool,
|
|
|
|
|
* active: bool,
|
|
|
|
|
* classes: string,
|
|
|
|
|
* unread: int,
|
|
|
|
|
* }
|
2013-09-20 11:34:33 -04:00
|
|
|
*/
|
2025-12-17 05:15:38 -05:00
|
|
|
#[Consumable(since: '6.0.0')]
|
|
|
|
|
#[ExceptionalImplementable(app: 'guest')]
|
2013-09-20 11:34:33 -04:00
|
|
|
interface INavigationManager {
|
2019-02-18 03:12:11 -05:00
|
|
|
/**
|
|
|
|
|
* Navigation entries of the app navigation
|
|
|
|
|
* @since 16.0.0
|
|
|
|
|
*/
|
2020-04-10 10:54:27 -04:00
|
|
|
public const TYPE_APPS = 'link';
|
2019-02-18 03:12:11 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Navigation entries of the settings navigation
|
|
|
|
|
* @since 16.0.0
|
|
|
|
|
*/
|
2020-04-10 10:54:27 -04:00
|
|
|
public const TYPE_SETTINGS = 'settings';
|
2019-02-18 03:12:11 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Navigation entries for public page footer navigation
|
|
|
|
|
* @since 16.0.0
|
|
|
|
|
*/
|
2020-04-10 10:54:27 -04:00
|
|
|
public const TYPE_GUEST = 'guest';
|
2019-02-18 03:12:11 -05:00
|
|
|
|
2025-12-17 05:15:38 -05:00
|
|
|
/**
|
|
|
|
|
* All navigation entries
|
|
|
|
|
* @since 33.0.0
|
|
|
|
|
*/
|
|
|
|
|
public const TYPE_ALL = 'all';
|
|
|
|
|
|
2013-09-20 11:34:33 -04:00
|
|
|
/**
|
|
|
|
|
* Creates a new navigation entry
|
2015-03-16 11:17:43 -04:00
|
|
|
*
|
2025-12-17 05:15:38 -05:00
|
|
|
* @param NavigationEntry|callable():NavigationEntry $entry If a menu entry (type = 'link') is added, you shall also set app to the app that
|
|
|
|
|
* added the entry. The use of a closure is preferred, because it will avoid loading
|
|
|
|
|
* the routing of your app, unless required.
|
2014-02-06 10:30:58 -05:00
|
|
|
* @return void
|
2015-04-16 11:00:08 -04:00
|
|
|
* @since 6.0.0
|
2013-09-20 11:34:33 -04:00
|
|
|
*/
|
2025-12-17 05:15:38 -05:00
|
|
|
public function add(array|callable $entry): void;
|
2013-09-20 11:34:33 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sets the current navigation entry of the currently running app
|
|
|
|
|
* @param string $appId id of the app entry to activate (from added $entry)
|
2014-02-06 10:30:58 -05:00
|
|
|
* @return void
|
2015-04-16 11:00:08 -04:00
|
|
|
* @since 6.0.0
|
2013-09-20 11:34:33 -04:00
|
|
|
*/
|
2025-12-17 05:15:38 -05:00
|
|
|
public function setActiveEntry(string $appId): void;
|
2018-01-29 06:17:47 -05:00
|
|
|
|
2020-08-04 04:00:27 -04:00
|
|
|
/**
|
|
|
|
|
* Get the current navigation entry of the currently running app
|
2025-12-17 05:15:38 -05:00
|
|
|
* @return ?string
|
2020-08-04 04:00:27 -04:00
|
|
|
* @since 20.0.0
|
|
|
|
|
*/
|
2025-12-17 05:15:38 -05:00
|
|
|
public function getActiveEntry(): ?string;
|
2020-08-04 04:00:27 -04:00
|
|
|
|
2018-01-29 06:17:47 -05:00
|
|
|
/**
|
|
|
|
|
* Get a list of navigation entries
|
|
|
|
|
*
|
2025-12-17 05:15:38 -05:00
|
|
|
* @param self::TYPE_APPS|self::TYPE_SETTINGS|self::TYPE_GUEST|self::TYPE_ALL $type type of the navigation entries
|
|
|
|
|
* @return array<string, NavigationEntryOutput>
|
2018-01-29 06:17:47 -05:00
|
|
|
* @since 14.0.0
|
|
|
|
|
*/
|
2019-02-18 03:12:11 -05:00
|
|
|
public function getAll(string $type = self::TYPE_APPS): array;
|
2021-05-11 02:22:51 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set an unread counter for navigation entries
|
|
|
|
|
*
|
|
|
|
|
* @param string $id id of the navigation entry
|
|
|
|
|
* @param int $unreadCounter Number of unread entries (0 to hide the counter which is the default)
|
|
|
|
|
* @since 22.0.0
|
|
|
|
|
*/
|
|
|
|
|
public function setUnreadCounter(string $id, int $unreadCounter): void;
|
2024-08-27 06:13:04 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get a navigation entry by id.
|
|
|
|
|
*
|
|
|
|
|
* @param string $id ID of the navigation entry
|
|
|
|
|
* @since 31.0.0
|
|
|
|
|
*/
|
|
|
|
|
public function get(string $id): ?array;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the id of the user's default entry
|
|
|
|
|
*
|
2025-12-17 05:15:38 -05:00
|
|
|
* If `user` is not passed, the currently logged-in user will be used
|
2024-08-27 06:13:04 -04:00
|
|
|
*
|
|
|
|
|
* @param ?IUser $user User to query default entry for
|
|
|
|
|
* @param bool $withFallbacks Include fallback values if no default entry was configured manually
|
|
|
|
|
* Before falling back to predefined default entries,
|
|
|
|
|
* the user defined entry order is considered and the first entry would be used as the fallback.
|
|
|
|
|
* @since 31.0.0
|
|
|
|
|
*/
|
|
|
|
|
public function getDefaultEntryIdForUser(?IUser $user = null, bool $withFallbacks = true): string;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the global default entries with fallbacks
|
|
|
|
|
*
|
|
|
|
|
* @return string[] The default entries
|
|
|
|
|
* @since 31.0.0
|
|
|
|
|
*/
|
|
|
|
|
public function getDefaultEntryIds(): array;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set the global default entries with fallbacks
|
|
|
|
|
*
|
|
|
|
|
* @param string[] $ids
|
|
|
|
|
* @throws \InvalidArgumentException If any of the entries is not available
|
|
|
|
|
* @since 31.0.0
|
|
|
|
|
*/
|
|
|
|
|
public function setDefaultEntryIds(array $ids): void;
|
2013-09-20 15:45:27 -04:00
|
|
|
}
|