diff options
author | Morris Jobke <hey@morrisjobke.de> | 2020-07-08 14:19:00 +0300 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2020-07-09 15:13:18 +0300 |
commit | 29ffaa567640d1766156f18a8e25e1ebaadb5449 (patch) | |
tree | b326a76bd8c4926d459006e146dbcb557b05d915 /apps/files_versions | |
parent | 18acb137d3b973f04ee039fd4a4e8ed1bca25127 (diff) |
Move files_versions to bootstrap mechanism
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
Diffstat (limited to 'apps/files_versions')
-rw-r--r-- | apps/files_versions/appinfo/app.php | 24 | ||||
-rw-r--r-- | apps/files_versions/lib/AppInfo/Application.php | 53 | ||||
-rw-r--r-- | apps/files_versions/tests/VersioningTest.php | 2 |
3 files changed, 24 insertions, 55 deletions
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 @@ -<?php -/** - * @copyright Copyright (c) 2016, ownCloud, Inc. - * - * @author John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> - * @author Victor Dubiniuk <dubiniuk@owncloud.com> - * - * @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 <http://www.gnu.org/licenses/> - * - */ - -\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; |