]> source.dussan.org Git - nextcloud-server.git/commitdiff
Move systemtags to the new bootstrap mechanism 21460/head
authorChristoph Wurst <christoph@winzerhof-wurst.at>
Wed, 17 Jun 2020 17:04:27 +0000 (19:04 +0200)
committerChristoph Wurst <christoph@winzerhof-wurst.at>
Wed, 17 Jun 2020 17:07:47 +0000 (19:07 +0200)
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
apps/systemtags/appinfo/app.php [deleted file]
apps/systemtags/composer/composer/autoload_classmap.php
apps/systemtags/composer/composer/autoload_static.php
apps/systemtags/lib/AppInfo/Application.php [new file with mode: 0644]

diff --git a/apps/systemtags/appinfo/app.php b/apps/systemtags/appinfo/app.php
deleted file mode 100644 (file)
index 0e408f8..0000000
+++ /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'),
-       ];
-});
index 9bf1f0cdaa4a3c55aaa6f799fc011a14866cc022..d0075a2549a9881ed51cc1a3201ba0ac55b0a262 100644 (file)
@@ -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',
 );
index 40615430f93e4054d6853867c8eb212aab3c08e3..197cd4437ab09d3c2ed375e3bde7eb42c0ef4f3f 100644 (file)
@@ -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 (file)
index 0000000..45ac2dc
--- /dev/null
@@ -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'),
+                       ];
+               });
+       }
+}