Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/URLGenerator.php')
-rw-r--r--lib/private/URLGenerator.php35
1 files changed, 28 insertions, 7 deletions
diff --git a/lib/private/URLGenerator.php b/lib/private/URLGenerator.php
index 47979a038ba..6115d4a221e 100644
--- a/lib/private/URLGenerator.php
+++ b/lib/private/URLGenerator.php
@@ -42,6 +42,8 @@ namespace OC;
use OC\Route\Router;
use OCA\Theming\ThemingDefaults;
+use OCP\App\AppPathNotFoundException;
+use OCP\App\IAppManager;
use OCP\ICacheFactory;
use OCP\IConfig;
use OCP\IRequest;
@@ -65,12 +67,14 @@ class URLGenerator implements IURLGenerator {
private $router;
/** @var null|string */
private $baseUrl = null;
+ private ?IAppManager $appManager = null;
public function __construct(IConfig $config,
IUserSession $userSession,
ICacheFactory $cacheFactory,
IRequest $request,
- Router $router) {
+ Router $router
+ ) {
$this->config = $config;
$this->userSession = $userSession;
$this->cacheFactory = $cacheFactory;
@@ -78,6 +82,14 @@ class URLGenerator implements IURLGenerator {
$this->router = $router;
}
+ private function getAppManager(): IAppManager {
+ if ($this->appManager !== null) {
+ return $this->appManager;
+ }
+ $this->appManager = \OCP\Server::get(IAppManager::class);
+ return $this->appManager;
+ }
+
/**
* Creates an url using a defined route
*
@@ -132,7 +144,7 @@ class URLGenerator implements IURLGenerator {
$frontControllerActive = ($this->config->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true');
if ($appName !== '') {
- $app_path = \OC_App::getAppPath($appName);
+ $app_path = $this->getAppManager()->getAppPath($appName);
// Check if the app is in the app folder
if ($app_path && file_exists($app_path . '/' . $file)) {
if (substr($file, -3) === 'php') {
@@ -142,7 +154,7 @@ class URLGenerator implements IURLGenerator {
}
$urlLinkTo .= ($file !== 'index.php') ? '/' . $file : '';
} else {
- $urlLinkTo = \OC_App::getAppWebPath($appName) . '/' . $file;
+ $urlLinkTo = $this->getAppManager()->getAppWebPath($appName) . '/' . $file;
}
} else {
$urlLinkTo = \OC::$WEBROOT . '/' . $appName . '/' . $file;
@@ -189,11 +201,20 @@ class URLGenerator implements IURLGenerator {
//if a theme has a png but not an svg always use the png
$basename = substr(basename($file), 0, -4);
- $appPath = \OC_App::getAppPath($appName);
+ try {
+ $appPath = $this->getAppManager()->getAppPath($appName);
+ } catch (AppPathNotFoundException $e) {
+ if ($appName === 'core' || $appName === '') {
+ $appName = 'core';
+ $appPath = false;
+ } else {
+ throw new RuntimeException('image not found: image: ' . $file . ' webroot: ' . \OC::$WEBROOT . ' serverroot: ' . \OC::$SERVERROOT);
+ }
+ }
// Check if the app is in the app folder
$path = '';
- $themingEnabled = $this->config->getSystemValue('installed', false) && \OCP\App::isEnabled('theming') && \OC_App::isAppLoaded('theming');
+ $themingEnabled = $this->config->getSystemValue('installed', false) && $this->getAppManager()->isEnabledForUser('theming');
$themingImagePath = false;
if ($themingEnabled) {
$themingDefaults = \OC::$server->getThemingDefaults();
@@ -220,10 +241,10 @@ class URLGenerator implements IURLGenerator {
} elseif ($themingEnabled && $themingImagePath) {
$path = $themingImagePath;
} elseif ($appPath && file_exists($appPath . "/img/$file")) {
- $path = \OC_App::getAppWebPath($appName) . "/img/$file";
+ $path = $this->getAppManager()->getAppWebPath($appName) . "/img/$file";
} elseif ($appPath && !file_exists($appPath . "/img/$basename.svg")
&& file_exists($appPath . "/img/$basename.png")) {
- $path = \OC_App::getAppWebPath($appName) . "/img/$basename.png";
+ $path = $this->getAppManager()->getAppWebPath($appName) . "/img/$basename.png";
} elseif (!empty($appName) and file_exists(\OC::$SERVERROOT . "/$appName/img/$file")) {
$path = \OC::$WEBROOT . "/$appName/img/$file";
} elseif (!empty($appName) and (!file_exists(\OC::$SERVERROOT . "/$appName/img/$basename.svg")