aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorprovokateurin <kate@provokateurin.de>2024-08-27 13:12:21 +0200
committerprovokateurin <kate@provokateurin.de>2024-09-09 11:04:36 +0200
commit01ec6762a249dbedc0bee452eb698c1dc6a52431 (patch)
tree9edfb9a7567b6fbcefa02a7bb70af48da83fefb2 /lib
parent70ed08daf1d6845af5df3a4a0b06eb73d190c6cf (diff)
downloadnextcloud-server-01ec6762a249dbedc0bee452eb698c1dc6a52431.tar.gz
nextcloud-server-01ec6762a249dbedc0bee452eb698c1dc6a52431.zip
fix(URLGenerator): Use NavigationManager to generate default page URL
Signed-off-by: provokateurin <kate@provokateurin.de>
Diffstat (limited to 'lib')
-rw-r--r--lib/private/URLGenerator.php25
1 files changed, 19 insertions, 6 deletions
diff --git a/lib/private/URLGenerator.php b/lib/private/URLGenerator.php
index 1ddc9aaa0e1..7a23f36b7e7 100644
--- a/lib/private/URLGenerator.php
+++ b/lib/private/URLGenerator.php
@@ -14,6 +14,7 @@ use OCP\App\AppPathNotFoundException;
use OCP\App\IAppManager;
use OCP\ICacheFactory;
use OCP\IConfig;
+use OCP\INavigationManager;
use OCP\IRequest;
use OCP\IURLGenerator;
use OCP\IUserSession;
@@ -36,6 +37,7 @@ class URLGenerator implements IURLGenerator {
/** @var null|string */
private $baseUrl = null;
private ?IAppManager $appManager = null;
+ private ?INavigationManager $navigationManager = null;
public function __construct(IConfig $config,
IUserSession $userSession,
@@ -58,6 +60,14 @@ class URLGenerator implements IURLGenerator {
return $this->appManager;
}
+ private function getNavigationManager(): INavigationManager {
+ if ($this->navigationManager !== null) {
+ return $this->navigationManager;
+ }
+ $this->navigationManager = \OCP\Server::get(INavigationManager::class);
+ return $this->navigationManager;
+ }
+
/**
* Creates an url using a defined route
*
@@ -288,14 +298,17 @@ class URLGenerator implements IURLGenerator {
return $this->getAbsoluteURL($defaultPage);
}
- $appId = $this->getAppManager()->getDefaultAppForUser();
-
- if ($this->config->getSystemValueBool('htaccess.IgnoreFrontController', false)
- || getenv('front_controller_active') === 'true') {
- return $this->getAbsoluteURL('/apps/' . $appId . '/');
+ $entryId = $this->getNavigationManager()->getDefaultEntryIdForUser();
+ $entry = $this->getNavigationManager()->get($entryId);
+ $href = (string)$entry['href'];
+ if ($href === '') {
+ throw new \InvalidArgumentException('Default navigation entry is missing href: ' . $entryId);
+ }
+ if (str_starts_with($href, '/index.php/') && ($this->config->getSystemValueBool('htaccess.IgnoreFrontController', false) || getenv('front_controller_active') === 'true')) {
+ $href = substr($href, 10);
}
- return $this->getAbsoluteURL('/index.php/apps/' . $appId . '/');
+ return $this->getAbsoluteURL($href);
}
/**