mirror of https://github.com/nextcloud/server
fix: Migrate a few more classes away from OC_App::getAppPath
Also fixed AppTest Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
This commit is contained in:
parent
0e7bac72ae
commit
733a818139
|
@ -402,7 +402,7 @@ class AppSettingsController extends Controller {
|
|||
try {
|
||||
$this->appManager->getAppPath($app['id']);
|
||||
$existsLocally = true;
|
||||
} catch (AppPathNotFoundException $e) {
|
||||
} catch (AppPathNotFoundException) {
|
||||
$existsLocally = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -560,12 +560,13 @@ class Installer {
|
|||
if ($output instanceof IOutput) {
|
||||
$output->debug('Installing ' . $app);
|
||||
}
|
||||
//install the database
|
||||
$appPath = OC_App::getAppPath($app);
|
||||
\OC_App::registerAutoloading($app, $appPath);
|
||||
|
||||
$appManager = \OCP\Server::get(IAppManager::class);
|
||||
$config = \OCP\Server::get(IConfig::class);
|
||||
|
||||
$appPath = $appManager->getAppPath($app);
|
||||
\OC_App::registerAutoloading($app, $appPath);
|
||||
|
||||
$ms = new MigrationService($app, \OCP\Server::get(Connection::class));
|
||||
if ($output instanceof IOutput) {
|
||||
$ms->setOutput($output);
|
||||
|
|
|
@ -40,6 +40,8 @@ declare(strict_types=1);
|
|||
|
||||
namespace OC\L10N;
|
||||
|
||||
use OCP\App\AppPathNotFoundException;
|
||||
use OCP\App\IAppManager;
|
||||
use OCP\ICache;
|
||||
use OCP\ICacheFactory;
|
||||
use OCP\IConfig;
|
||||
|
@ -88,38 +90,17 @@ class Factory implements IFactory {
|
|||
'pt_BR', 'pt_PT', 'da', 'fi_FI', 'nb_NO', 'sv', 'tr', 'zh_CN', 'ko'
|
||||
];
|
||||
|
||||
/** @var IConfig */
|
||||
protected $config;
|
||||
|
||||
/** @var IRequest */
|
||||
protected $request;
|
||||
|
||||
/** @var IUserSession */
|
||||
protected IUserSession $userSession;
|
||||
|
||||
private ICache $cache;
|
||||
|
||||
/** @var string */
|
||||
protected $serverRoot;
|
||||
|
||||
/**
|
||||
* @param IConfig $config
|
||||
* @param IRequest $request
|
||||
* @param IUserSession $userSession
|
||||
* @param string $serverRoot
|
||||
*/
|
||||
public function __construct(
|
||||
IConfig $config,
|
||||
IRequest $request,
|
||||
IUserSession $userSession,
|
||||
protected IConfig $config,
|
||||
protected IRequest $request,
|
||||
protected IUserSession $userSession,
|
||||
ICacheFactory $cacheFactory,
|
||||
$serverRoot
|
||||
protected string $serverRoot,
|
||||
protected IAppManager $appManager,
|
||||
) {
|
||||
$this->config = $config;
|
||||
$this->request = $request;
|
||||
$this->userSession = $userSession;
|
||||
$this->cache = $cacheFactory->createLocal('L10NFactory');
|
||||
$this->serverRoot = $serverRoot;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -562,9 +543,7 @@ class Factory implements IFactory {
|
|||
* @param string $lang
|
||||
* @return string[]
|
||||
*/
|
||||
// FIXME This method is only public, until OC_L10N does not need it anymore,
|
||||
// FIXME This is also the reason, why it is not in the public interface
|
||||
public function getL10nFilesForApp($app, $lang) {
|
||||
private function getL10nFilesForApp($app, $lang) {
|
||||
$languageFiles = [];
|
||||
|
||||
$i18nDir = $this->findL10nDir($app);
|
||||
|
@ -572,7 +551,7 @@ class Factory implements IFactory {
|
|||
|
||||
if (($this->isSubDirectory($transFile, $this->serverRoot . '/core/l10n/')
|
||||
|| $this->isSubDirectory($transFile, $this->serverRoot . '/lib/l10n/')
|
||||
|| $this->isSubDirectory($transFile, \OC_App::getAppPath($app) . '/l10n/'))
|
||||
|| $this->isSubDirectory($transFile, $this->appManager->getAppPath($app) . '/l10n/'))
|
||||
&& file_exists($transFile)
|
||||
) {
|
||||
// load the translations file
|
||||
|
@ -602,9 +581,12 @@ class Factory implements IFactory {
|
|||
if (file_exists($this->serverRoot . '/' . $app . '/l10n/')) {
|
||||
return $this->serverRoot . '/' . $app . '/l10n/';
|
||||
}
|
||||
} elseif ($app && \OC_App::getAppPath($app) !== false) {
|
||||
// Check if the app is in the app folder
|
||||
return \OC_App::getAppPath($app) . '/l10n/';
|
||||
} elseif ($app) {
|
||||
try {
|
||||
return $this->appManager->getAppPath($app) . '/l10n/';
|
||||
} catch (AppPathNotFoundException) {
|
||||
/* App not found, continue */
|
||||
}
|
||||
}
|
||||
return $this->serverRoot . '/core/l10n/';
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
*/
|
||||
namespace OC\Route;
|
||||
|
||||
use OCP\App\IAppManager;
|
||||
use OCP\Diagnostics\IEventLogger;
|
||||
use OCP\ICache;
|
||||
use OCP\ICacheFactory;
|
||||
|
@ -41,10 +42,11 @@ class CachingRouter extends Router {
|
|||
IRequest $request,
|
||||
IConfig $config,
|
||||
IEventLogger $eventLogger,
|
||||
ContainerInterface $container
|
||||
ContainerInterface $container,
|
||||
IAppManager $appManager,
|
||||
) {
|
||||
$this->cache = $cacheFactory->createLocal('route');
|
||||
parent::__construct($logger, $request, $config, $eventLogger, $container);
|
||||
parent::__construct($logger, $request, $config, $eventLogger, $container, $appManager);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -35,6 +35,8 @@ namespace OC\Route;
|
|||
|
||||
use DirectoryIterator;
|
||||
use OC\AppFramework\Routing\RouteParser;
|
||||
use OCP\App\AppPathNotFoundException;
|
||||
use OCP\App\IAppManager;
|
||||
use OCP\AppFramework\App;
|
||||
use OCP\AppFramework\Http\Attribute\Route as RouteAttribute;
|
||||
use OCP\Diagnostics\IEventLogger;
|
||||
|
@ -71,22 +73,17 @@ class Router implements IRouter {
|
|||
protected $loaded = false;
|
||||
/** @var array */
|
||||
protected $loadedApps = [];
|
||||
protected LoggerInterface $logger;
|
||||
/** @var RequestContext */
|
||||
protected $context;
|
||||
private IEventLogger $eventLogger;
|
||||
private IConfig $config;
|
||||
private ContainerInterface $container;
|
||||
|
||||
public function __construct(
|
||||
LoggerInterface $logger,
|
||||
protected LoggerInterface $logger,
|
||||
IRequest $request,
|
||||
IConfig $config,
|
||||
IEventLogger $eventLogger,
|
||||
ContainerInterface $container
|
||||
private IConfig $config,
|
||||
private IEventLogger $eventLogger,
|
||||
private ContainerInterface $container,
|
||||
private IAppManager $appManager,
|
||||
) {
|
||||
$this->logger = $logger;
|
||||
$this->config = $config;
|
||||
$baseUrl = \OC::$WEBROOT;
|
||||
if (!($config->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true')) {
|
||||
$baseUrl .= '/index.php';
|
||||
|
@ -101,8 +98,6 @@ class Router implements IRouter {
|
|||
$this->context = new RequestContext($baseUrl, $method, $host, $schema);
|
||||
// TODO cache
|
||||
$this->root = $this->getCollection('root');
|
||||
$this->eventLogger = $eventLogger;
|
||||
$this->container = $container;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -114,12 +109,14 @@ class Router implements IRouter {
|
|||
if ($this->routingFiles === null) {
|
||||
$this->routingFiles = [];
|
||||
foreach (\OC_APP::getEnabledApps() as $app) {
|
||||
$appPath = \OC_App::getAppPath($app);
|
||||
if ($appPath !== false) {
|
||||
try {
|
||||
$appPath = $this->appManager->getAppPath($app);
|
||||
$file = $appPath . '/appinfo/routes.php';
|
||||
if (file_exists($file)) {
|
||||
$this->routingFiles[$app] = $file;
|
||||
}
|
||||
} catch (AppPathNotFoundException) {
|
||||
/* ignore */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -653,7 +653,8 @@ class Server extends ServerContainer implements IServerContainer {
|
|||
$c->getRequest(),
|
||||
$c->get(IUserSession::class),
|
||||
$c->get(ICacheFactory::class),
|
||||
\OC::$SERVERROOT
|
||||
\OC::$SERVERROOT,
|
||||
$c->get(IAppManager::class),
|
||||
);
|
||||
});
|
||||
/** @deprecated 19.0.0 */
|
||||
|
|
|
@ -560,7 +560,6 @@ class AppTest extends \Test\TestCase {
|
|||
$this->overwriteService(AppManager::class, new AppManager(
|
||||
\OC::$server->getUserSession(),
|
||||
\OC::$server->getConfig(),
|
||||
$appConfig,
|
||||
\OC::$server->getGroupManager(),
|
||||
\OC::$server->getMemCacheFactory(),
|
||||
\OC::$server->get(IEventDispatcher::class),
|
||||
|
|
Loading…
Reference in New Issue