INavigationManager
in
Manages the Nextcloud navigation
Tags
Attributes
- #[Consumable]
- $since: '6.0.0'
- #[ExceptionalImplementable]
- $app: 'guest'
Table of Contents
Constants
- TYPE_ALL = 'all'
- All navigation entries
- TYPE_APPS = 'link'
- Navigation entries of the app navigation
- TYPE_GUEST = 'guest'
- Navigation entries for public page footer navigation
- TYPE_SETTINGS = 'settings'
- Navigation entries of the settings navigation
Methods
- add() : void
- Creates a new navigation entry
- get() : array<string|int, mixed>|null
- Get a navigation entry by id.
- getActiveEntry() : string|null
- Get the current navigation entry of the currently running app
- getAll() : array<string, NavigationEntryOutput>
- Get a list of navigation entries
- getDefaultEntryIdForUser() : string
- Returns the id of the user's default entry
- getDefaultEntryIds() : array<string|int, string>
- Get the global default entries with fallbacks
- setActiveEntry() : void
- Sets the current navigation entry of the currently running app
- setDefaultEntryIds() : void
- Set the global default entries with fallbacks
- setUnreadCounter() : void
- Set an unread counter for navigation entries
Constants
TYPE_ALL
All navigation entries
public
mixed
TYPE_ALL
= 'all'
Tags
TYPE_APPS
Navigation entries of the app navigation
public
mixed
TYPE_APPS
= 'link'
Tags
TYPE_GUEST
Navigation entries for public page footer navigation
public
mixed
TYPE_GUEST
= 'guest'
Tags
TYPE_SETTINGS
Navigation entries of the settings navigation
public
mixed
TYPE_SETTINGS
= 'settings'
Tags
Methods
add()
Creates a new navigation entry
public
add(NavigationEntry|callable(): NavigationEntry $entry) : void
Parameters
- $entry : NavigationEntry|callable(): NavigationEntry
-
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.
Tags
get()
Get a navigation entry by id.
public
get(string $id) : array<string|int, mixed>|null
Parameters
- $id : string
-
ID of the navigation entry
Tags
Return values
array<string|int, mixed>|nullgetActiveEntry()
Get the current navigation entry of the currently running app
public
getActiveEntry() : string|null
Tags
Return values
string|nullgetAll()
Get a list of navigation entries
public
getAll([self::TYPE_APPS|self::TYPE_SETTINGS|self::TYPE_GUEST|self::TYPE_ALL $type = self::TYPE_APPS ]) : array<string, NavigationEntryOutput>
Parameters
- $type : self::TYPE_APPS|self::TYPE_SETTINGS|self::TYPE_GUEST|self::TYPE_ALL = self::TYPE_APPS
-
type of the navigation entries
Tags
Return values
array<string, NavigationEntryOutput>getDefaultEntryIdForUser()
Returns the id of the user's default entry
public
getDefaultEntryIdForUser([IUser|null $user = null ][, bool $withFallbacks = true ]) : string
If user is not passed, the currently logged-in user will be used
Parameters
- $user : IUser|null = null
-
User to query default entry for
- $withFallbacks : bool = true
-
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.
Tags
Return values
stringgetDefaultEntryIds()
Get the global default entries with fallbacks
public
getDefaultEntryIds() : array<string|int, string>
Tags
Return values
array<string|int, string> —The default entries
setActiveEntry()
Sets the current navigation entry of the currently running app
public
setActiveEntry(string $appId) : void
Parameters
- $appId : string
-
id of the app entry to activate (from added $entry)
Tags
setDefaultEntryIds()
Set the global default entries with fallbacks
public
setDefaultEntryIds(array<string|int, string> $ids) : void
Parameters
- $ids : array<string|int, string>
Tags
setUnreadCounter()
Set an unread counter for navigation entries
public
setUnreadCounter(string $id, int $unreadCounter) : void
Parameters
- $id : string
-
id of the navigation entry
- $unreadCounter : int
-
Number of unread entries (0 to hide the counter which is the default)