diff --git a/apps/files_versions/appinfo/app.php b/apps/files_versions/appinfo/app.php deleted file mode 100644 index 917b8831c06..00000000000 --- a/apps/files_versions/appinfo/app.php +++ /dev/null @@ -1,24 +0,0 @@ - - * @author Victor Dubiniuk - * - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see - * - */ - -\OC::$server->query(\OCA\Files_Versions\AppInfo\Application::class); diff --git a/apps/files_versions/lib/AppInfo/Application.php b/apps/files_versions/lib/AppInfo/Application.php index c078e05bfef..82a12fbc5b0 100644 --- a/apps/files_versions/lib/AppInfo/Application.php +++ b/apps/files_versions/lib/AppInfo/Application.php @@ -38,31 +38,32 @@ use OCA\Files_Versions\Listener\LoadAdditionalListener; use OCA\Files_Versions\Listener\LoadSidebarListener; use OCA\Files_Versions\Versions\IVersionManager; use OCA\Files_Versions\Versions\VersionManager; +use OCP\App\IAppManager; use OCP\AppFramework\App; +use OCP\AppFramework\Bootstrap\IBootContext; +use OCP\AppFramework\Bootstrap\IBootstrap; +use OCP\AppFramework\Bootstrap\IRegistrationContext; use OCP\AppFramework\IAppContainer; -use OCP\EventDispatcher\IEventDispatcher; +use OCP\ILogger; +use OCP\IServerContainer; -class Application extends App { +class Application extends App implements IBootstrap { public const APP_ID = 'files_versions'; public function __construct(array $urlParams = []) { parent::__construct(self::APP_ID, $urlParams); + } - $container = $this->getContainer(); - $server = $container->getServer(); - - /** @var IEventDispatcher $newDispatcher */ - $dispatcher = $server->query(IEventDispatcher::class); - + public function register(IRegistrationContext $context): void { /** * Register capabilities */ - $container->registerCapability(Capabilities::class); + $context->registerCapability(Capabilities::class); /** * Register $principalBackend for the DAV collection */ - $container->registerService('principalBackend', function (IAppContainer $c) { + $context->registerService('principalBackend', function (IAppContainer $c) { $server = $c->getServer(); return new Principal( $server->getUserManager(), @@ -71,20 +72,23 @@ class Application extends App { $server->getUserSession(), $server->getAppManager(), $server->query(ProxyMapper::class), - \OC::$server->getConfig() + $server->getConfig() ); }); - $container->registerService(IVersionManager::class, function (IAppContainer $c) { + $context->registerService(IVersionManager::class, function (IAppContainer $c) { return new VersionManager(); }); - $this->registerVersionBackends(); - /** * Register Events */ - $this->registerEvents($dispatcher); + $context->registerEventListener(LoadAdditionalScriptsEvent::class, LoadAdditionalListener::class); + $context->registerEventListener(LoadSidebar::class, LoadSidebarListener::class); + } + + public function boot(IBootContext $context): void { + $context->injectFn(\Closure::fromCallable([$this, 'registerVersionBackends'])); /** * Register hooks @@ -92,19 +96,17 @@ class Application extends App { Hooks::connectHooks(); } - public function registerVersionBackends() { - $server = $this->getContainer()->getServer(); - $appManager = $server->getAppManager(); + public function registerVersionBackends(IServerContainer $server, IAppManager $appManager, ILogger $logger) { foreach ($appManager->getInstalledApps() as $app) { $appInfo = $appManager->getAppInfo($app); if (isset($appInfo['versions'])) { $backends = $appInfo['versions']; foreach ($backends as $backend) { if (isset($backend['@value'])) { - $this->loadBackend($backend); + $this->loadBackend($backend, $server, $logger); } else { foreach ($backend as $singleBackend) { - $this->loadBackend($singleBackend); + $this->loadBackend($singleBackend, $server, $logger); } } } @@ -112,11 +114,9 @@ class Application extends App { } } - private function loadBackend(array $backend) { - $server = $this->getContainer()->getServer(); - $logger = $server->getLogger(); + private function loadBackend(array $backend, IServerContainer $server, ILogger $logger) { /** @var IVersionManager $versionManager */ - $versionManager = $this->getContainer()->getServer()->query(IVersionManager::class); + $versionManager = $server->query(IVersionManager::class); $class = $backend['@value']; $for = $backend['@attributes']['for']; try { @@ -126,9 +126,4 @@ class Application extends App { $logger->logException($e); } } - - protected function registerEvents(IEventDispatcher $dispatcher) { - $dispatcher->addServiceListener(LoadAdditionalScriptsEvent::class, LoadAdditionalListener::class); - $dispatcher->addServiceListener(LoadSidebar::class, LoadSidebarListener::class); - } } diff --git a/apps/files_versions/tests/VersioningTest.php b/apps/files_versions/tests/VersioningTest.php index b146e51c407..683fc078a29 100644 --- a/apps/files_versions/tests/VersioningTest.php +++ b/apps/files_versions/tests/VersioningTest.php @@ -35,8 +35,6 @@ namespace OCA\Files_Versions\Tests; -require_once __DIR__ . '/../appinfo/app.php'; - use OC\Files\Storage\Temporary; use OCP\IConfig; use OCP\IUser;