aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/URLGenerator.php
diff options
context:
space:
mode:
authorDaniel Rudolf <github.com@daniel-rudolf.de>2021-07-01 16:26:55 +0200
committerDaniel Rudolf <github.com@daniel-rudolf.de>2021-07-01 16:26:55 +0200
commit15a445f743ccf3bcdff69bf09e55367568411c36 (patch)
tree29dc7942b696a1190eb85aeae54e11c531d6756d /lib/private/URLGenerator.php
parente16bf707aab3c155f871f6ee6d60079932ecc014 (diff)
downloadnextcloud-server-15a445f743ccf3bcdff69bf09e55367568411c36.tar.gz
nextcloud-server-15a445f743ccf3bcdff69bf09e55367568411c36.zip
Move UtilTest::testDefaultApps() to UrlGeneratorTest
Signed-off-by: Daniel Rudolf <github.com@daniel-rudolf.de>
Diffstat (limited to 'lib/private/URLGenerator.php')
-rw-r--r--lib/private/URLGenerator.php15
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/private/URLGenerator.php b/lib/private/URLGenerator.php
index 1d8cb041611..7c97a76e257 100644
--- a/lib/private/URLGenerator.php
+++ b/lib/private/URLGenerator.php
@@ -42,6 +42,7 @@ namespace OC;
use OC\Route\Router;
use OCA\Theming\ThemingDefaults;
+use OCP\App\IAppManager;
use OCP\ICacheFactory;
use OCP\IConfig;
use OCP\IRequest;
@@ -55,6 +56,10 @@ use RuntimeException;
class URLGenerator implements IURLGenerator {
/** @var IConfig */
private $config;
+ /** @var IUserSession */
+ public $userSession;
+ /** @var IAppManager */
+ public $appManager;
/** @var ICacheFactory */
private $cacheFactory;
/** @var IRequest */
@@ -65,10 +70,14 @@ class URLGenerator implements IURLGenerator {
private $baseUrl = null;
public function __construct(IConfig $config,
+ IUserSession $userSession,
+ IAppManager $appManager,
ICacheFactory $cacheFactory,
IRequest $request,
Router $router) {
$this->config = $config;
+ $this->userSession = $userSession;
+ $this->appManager = $appManager;
$this->cacheFactory = $cacheFactory;
$this->request = $request;
$this->router = $router;
@@ -289,9 +298,7 @@ class URLGenerator implements IURLGenerator {
$appId = 'files';
$defaultApps = explode(',', $this->config->getSystemValue('defaultapp', 'dashboard,files'));
- /** @var IUserSession $userSession */
- $userSession = \OC::$server->get(IUserSession::class);
- $userId = $userSession->isLoggedIn() ? $userSession->getUser()->getUID() : null;
+ $userId = $this->userSession->isLoggedIn() ? $this->userSession->getUser()->getUID() : null;
if ($userId !== null) {
$userDefaultApps = explode(',', $this->config->getUserValue($userId, 'core', 'defaultapp'));
$defaultApps = array_filter(array_merge($userDefaultApps, $defaultApps));
@@ -300,7 +307,7 @@ class URLGenerator implements IURLGenerator {
// find the first app that is enabled for the current user
foreach ($defaultApps as $defaultApp) {
$defaultApp = \OC_App::cleanAppId(strip_tags($defaultApp));
- if (\OC::$server->getAppManager()->isEnabledForUser($defaultApp)) {
+ if ($this->appManager->isEnabledForUser($defaultApp)) {
$appId = $defaultApp;
break;
}