Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 18 additions & 16 deletions core/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,21 +170,23 @@ public function registerNavigationEntries(
IURLGenerator $urlGenerator,
IFactory $factory,
): void {
if (!$userSession->isLoggedIn()) {
return;
}

$l = $factory->get('core');

// Register the logout button in the user settings
$logoutUrl = $urlGenerator->getLogoutUrl();
$navigationManager->add([
'type' => 'settings',
'id' => 'logout',
'order' => 99999,
'href' => $logoutUrl,
'name' => $l->t('Log out'),
'icon' => $urlGenerator->imagePath('core', 'actions/logout.svg'),
]);
$navigationManager->add(function () use ($userSession, $factory, $urlGenerator): ?array {
if (!$userSession->isLoggedIn()) {
return null;
}

$l = $factory->get('core');

// Register the logout button in the user settings
$logoutUrl = $urlGenerator->getLogoutUrl();
return [
'type' => 'settings',
'id' => 'logout',
'order' => 99999,
'href' => $logoutUrl,
'name' => $l->t('Log out'),
'icon' => $urlGenerator->imagePath('core', 'actions/logout.svg'),
];
});
}
}
7 changes: 5 additions & 2 deletions lib/private/NavigationManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
class NavigationManager implements INavigationManager {
/** @var array<string, NavigationEntryOutput> */
protected array $entries = [];
/** @var list<callable(): NavigationEntry> */
/** @var list<callable(): ?NavigationEntry> */
protected array $closureEntries = [];
protected ?string $activeEntry = null;
protected array $unreadCounters = [];
Expand Down Expand Up @@ -208,7 +208,10 @@ private function init(): void {
private function resolveAppNavigationEntries(): void {
// Resolve app navigation closures
while ($c = array_pop($this->closureEntries)) {
$this->add($c());
$entry = $c();
if ($entry !== null) {
$this->add($entry);
}
}

// Resolve dynamically added navigation entries via event listeners
Expand Down
6 changes: 3 additions & 3 deletions lib/public/INavigationManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ interface INavigationManager {
/**
* Creates a new navigation entry
*
* @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.
* @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.
* @return void
* @since 6.0.0
*/
Expand Down
Loading