From 5ed54c024d3401cdde4c64a678d50e90ce7efdeb Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Wed, 17 Jun 2020 19:04:27 +0200 Subject: [PATCH] Move systemtags to the new bootstrap mechanism Signed-off-by: Christoph Wurst --- apps/systemtags/appinfo/app.php | 72 --------------- .../composer/composer/autoload_classmap.php | 1 + .../composer/composer/autoload_static.php | 1 + apps/systemtags/lib/AppInfo/Application.php | 88 +++++++++++++++++++ 4 files changed, 90 insertions(+), 72 deletions(-) delete mode 100644 apps/systemtags/appinfo/app.php create mode 100644 apps/systemtags/lib/AppInfo/Application.php diff --git a/apps/systemtags/appinfo/app.php b/apps/systemtags/appinfo/app.php deleted file mode 100644 index 0e408f8bf4..0000000000 --- a/apps/systemtags/appinfo/app.php +++ /dev/null @@ -1,72 +0,0 @@ - - * @author Joas Schilling - * @author Jörn Friedrich Dreyer - * @author Morris Jobke - * @author Robin Appelman - * @author Roeland Jago Douma - * @author Vincent Petry - * - * @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 - * - */ - -use OCP\SystemTag\ManagerEvent; -use OCP\SystemTag\MapperEvent; -use OCA\SystemTags\Activity\Listener; - -$eventDispatcher = \OC::$server->getEventDispatcher(); -$eventDispatcher->addListener( - 'OCA\Files::loadAdditionalScripts', - function () { - // FIXME: no public API for these ? - \OCP\Util::addScript('dist/systemtags'); - \OCP\Util::addScript('systemtags', 'systemtags'); - } -); - -$managerListener = function (ManagerEvent $event) { - /** @var \OCA\SystemTags\Activity\Listener $listener */ - $listener = \OC::$server->query(Listener::class); - $listener->event($event); -}; - -$eventDispatcher->addListener(ManagerEvent::EVENT_CREATE, $managerListener); -$eventDispatcher->addListener(ManagerEvent::EVENT_DELETE, $managerListener); -$eventDispatcher->addListener(ManagerEvent::EVENT_UPDATE, $managerListener); - -$mapperListener = function (MapperEvent $event) { - $application = new \OCP\AppFramework\App('systemtags'); - /** @var \OCA\SystemTags\Activity\Listener $listener */ - $listener = \OC::$server->query(Listener::class); - $listener->mapperEvent($event); -}; - -$eventDispatcher->addListener(MapperEvent::EVENT_ASSIGN, $mapperListener); -$eventDispatcher->addListener(MapperEvent::EVENT_UNASSIGN, $mapperListener); - -\OCA\Files\App::getNavigationManager()->add(function () { - $l = \OC::$server->getL10N('systemtags'); - return [ - 'id' => 'systemtagsfilter', - 'appname' => 'systemtags', - 'script' => 'list.php', - 'order' => 25, - 'name' => $l->t('Tags'), - ]; -}); diff --git a/apps/systemtags/composer/composer/autoload_classmap.php b/apps/systemtags/composer/composer/autoload_classmap.php index 9bf1f0cdaa..d0075a2549 100644 --- a/apps/systemtags/composer/composer/autoload_classmap.php +++ b/apps/systemtags/composer/composer/autoload_classmap.php @@ -9,6 +9,7 @@ return array( 'OCA\\SystemTags\\Activity\\Listener' => $baseDir . '/../lib/Activity/Listener.php', 'OCA\\SystemTags\\Activity\\Provider' => $baseDir . '/../lib/Activity/Provider.php', 'OCA\\SystemTags\\Activity\\Setting' => $baseDir . '/../lib/Activity/Setting.php', + 'OCA\\SystemTags\\AppInfo\\Application' => $baseDir . '/../lib/AppInfo/Application.php', 'OCA\\SystemTags\\Controller\\LastUsedController' => $baseDir . '/../lib/Controller/LastUsedController.php', 'OCA\\SystemTags\\Settings\\Admin' => $baseDir . '/../lib/Settings/Admin.php', ); diff --git a/apps/systemtags/composer/composer/autoload_static.php b/apps/systemtags/composer/composer/autoload_static.php index 40615430f9..197cd4437a 100644 --- a/apps/systemtags/composer/composer/autoload_static.php +++ b/apps/systemtags/composer/composer/autoload_static.php @@ -24,6 +24,7 @@ class ComposerStaticInitSystemTags 'OCA\\SystemTags\\Activity\\Listener' => __DIR__ . '/..' . '/../lib/Activity/Listener.php', 'OCA\\SystemTags\\Activity\\Provider' => __DIR__ . '/..' . '/../lib/Activity/Provider.php', 'OCA\\SystemTags\\Activity\\Setting' => __DIR__ . '/..' . '/../lib/Activity/Setting.php', + 'OCA\\SystemTags\\AppInfo\\Application' => __DIR__ . '/..' . '/../lib/AppInfo/Application.php', 'OCA\\SystemTags\\Controller\\LastUsedController' => __DIR__ . '/..' . '/../lib/Controller/LastUsedController.php', 'OCA\\SystemTags\\Settings\\Admin' => __DIR__ . '/..' . '/../lib/Settings/Admin.php', ); diff --git a/apps/systemtags/lib/AppInfo/Application.php b/apps/systemtags/lib/AppInfo/Application.php new file mode 100644 index 0000000000..45ac2dc1e8 --- /dev/null +++ b/apps/systemtags/lib/AppInfo/Application.php @@ -0,0 +1,88 @@ + + * + * @author 2020 Christoph Wurst + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * 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 + * along with this program. If not, see . + */ + +namespace OCA\SystemTags\AppInfo; + +use OCA\SystemTags\Activity\Listener; +use OCP\AppFramework\App; +use OCP\AppFramework\Bootstrap\IBootContext; +use OCP\AppFramework\Bootstrap\IBootstrap; +use OCP\AppFramework\Bootstrap\IRegistrationContext; +use OCP\SystemTag\ManagerEvent; +use OCP\SystemTag\MapperEvent; + +class Application extends App implements IBootstrap { + public const APP_ID = 'systemtags'; + + public function __construct() { + parent::__construct(self::APP_ID); + } + + public function register(IRegistrationContext $context): void { + } + + public function boot(IBootContext $context): void { + /* + * @todo move the OCP events and then move the registration to `register` + */ + $eventDispatcher = $context->getServerContainer()->getEventDispatcher(); + $eventDispatcher->addListener( + 'OCA\Files::loadAdditionalScripts', + function () { + // FIXME: no public API for these ? + \OCP\Util::addScript('dist/systemtags'); + \OCP\Util::addScript(self::APP_ID, 'systemtags'); + } + ); + + $managerListener = function (ManagerEvent $event) use ($context) { + /** @var \OCA\SystemTags\Activity\Listener $listener */ + $listener = $context->getServerContainer()->query(Listener::class); + $listener->event($event); + }; + $eventDispatcher->addListener(ManagerEvent::EVENT_CREATE, $managerListener); + $eventDispatcher->addListener(ManagerEvent::EVENT_DELETE, $managerListener); + $eventDispatcher->addListener(ManagerEvent::EVENT_UPDATE, $managerListener); + + $mapperListener = function (MapperEvent $event) use ($context) { + /** @var \OCA\SystemTags\Activity\Listener $listener */ + $listener = $context->getServerContainer()->query(Listener::class); + $listener->mapperEvent($event); + }; + $eventDispatcher->addListener(MapperEvent::EVENT_ASSIGN, $mapperListener); + $eventDispatcher->addListener(MapperEvent::EVENT_UNASSIGN, $mapperListener); + + \OCA\Files\App::getNavigationManager()->add(function () { + $l = \OC::$server->getL10N(self::APP_ID); + return [ + 'id' => 'systemtagsfilter', + 'appname' => self::APP_ID, + 'script' => 'list.php', + 'order' => 25, + 'name' => $l->t('Tags'), + ]; + }); + } +}