diff options
author | Morris Jobke <hey@morrisjobke.de> | 2020-07-06 23:06:10 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-06 23:06:10 +0200 |
commit | 6c6f41ca69c4edddf6d7c8dc4f22ac7fe04e0e7c (patch) | |
tree | 934aaf882012ae0aa7d4e5ad9ede4e69cfe1b753 /apps/systemtags | |
parent | 7ad0381e5cde66cdf802a9b8fe6a2f481741085f (diff) | |
parent | 5ed54c024d3401cdde4c64a678d50e90ce7efdeb (diff) | |
download | nextcloud-server-6c6f41ca69c4edddf6d7c8dc4f22ac7fe04e0e7c.tar.gz nextcloud-server-6c6f41ca69c4edddf6d7c8dc4f22ac7fe04e0e7c.zip |
Merge pull request #21460 from nextcloud/enhancement/systemtags-bootstrap
Move systemtags to the new bootstrap mechanism
Diffstat (limited to 'apps/systemtags')
-rw-r--r-- | apps/systemtags/appinfo/app.php | 72 | ||||
-rw-r--r-- | apps/systemtags/composer/composer/autoload_classmap.php | 1 | ||||
-rw-r--r-- | apps/systemtags/composer/composer/autoload_static.php | 1 | ||||
-rw-r--r-- | apps/systemtags/lib/AppInfo/Application.php | 88 |
4 files changed, 90 insertions, 72 deletions
diff --git a/apps/systemtags/appinfo/app.php b/apps/systemtags/appinfo/app.php deleted file mode 100644 index 0e408f8bf49..00000000000 --- a/apps/systemtags/appinfo/app.php +++ /dev/null @@ -1,72 +0,0 @@ -<?php -/** - * @copyright Copyright (c) 2016, ownCloud, Inc. - * - * @author Christoph Wurst <christoph@winzerhof-wurst.at> - * @author Joas Schilling <coding@schilljs.com> - * @author Jörn Friedrich Dreyer <jfd@butonic.de> - * @author Morris Jobke <hey@morrisjobke.de> - * @author Robin Appelman <robin@icewind.nl> - * @author Roeland Jago Douma <roeland@famdouma.nl> - * @author Vincent Petry <pvince81@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/> - * - */ - -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 9bf1f0cdaa4..d0075a2549a 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 40615430f93..197cd4437ab 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 00000000000..45ac2dc1e84 --- /dev/null +++ b/apps/systemtags/lib/AppInfo/Application.php @@ -0,0 +1,88 @@ +<?php + +declare(strict_types=1); + +/** + * @copyright 2020 Christoph Wurst <christoph@winzerhof-wurst.at> + * + * @author 2020 Christoph Wurst <christoph@winzerhof-wurst.at> + * + * @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 <http://www.gnu.org/licenses/>. + */ + +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'), + ]; + }); + } +} |