From 0049707ee97145fcf61cf1f24ffe51ce2637119a Mon Sep 17 00:00:00 2001 From: Alfred Egger Date: Thu, 17 Dec 2020 00:23:24 +0100 Subject: [PATCH] Fix app for Nextcloud 20 --- README.md | 2 +- appinfo/app.php | 12 ----- appinfo/info.xml | 2 +- lib/AppInfo/Application.php | 50 +++++++++++++++++++ .../LoadAdditionalScriptsListener.php | 41 +++++++++++++++ 5 files changed, 93 insertions(+), 14 deletions(-) delete mode 100644 appinfo/app.php create mode 100644 lib/AppInfo/Application.php create mode 100644 lib/Listener/LoadAdditionalScriptsListener.php diff --git a/README.md b/README.md index aba0cc5..c9124d8 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -Checksum +Printer ======== **App for [Nextcloud](https://nextcloud.com) to print files using the CUPS/LPR printing ecosystem.** diff --git a/appinfo/app.php b/appinfo/app.php deleted file mode 100644 index f540efa..0000000 --- a/appinfo/app.php +++ /dev/null @@ -1,12 +0,0 @@ -getEventDispatcher(); -$eventDispatcher->addListener('OCA\Files::loadAdditionalScripts', function(){ - Util::addScript('printer', 'printer.tabview' ); - Util::addScript('printer', 'printer.plugin' ); -}); diff --git a/appinfo/info.xml b/appinfo/info.xml index c576f0e..efd6878 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -28,6 +28,6 @@ https://github.com/e-alfred/nextcloud-printer/issues https://github.com/e-alfred/nextcloud-printer/raw/master/screenshots/printer.gif - + diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php new file mode 100644 index 0000000..d9aa391 --- /dev/null +++ b/lib/AppInfo/Application.php @@ -0,0 +1,50 @@ + + * + * @author Richard Steinmetz + * + * 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\Printer\AppInfo; + +use OCA\Printer\Listener\LoadAdditionalScriptsListener; +use OCA\Files\Event\LoadAdditionalScriptsEvent; +use OCP\AppFramework\App; +use OCP\AppFramework\Bootstrap\IBootContext; +use OCP\AppFramework\Bootstrap\IBootstrap; +use OCP\AppFramework\Bootstrap\IRegistrationContext; + +class Application extends App implements IBootstrap { + public const APP_ID = 'printer'; + + public function __construct(array $urlParams = []) { + parent::__construct(self::APP_ID, $urlParams); + } + + public function register(IRegistrationContext $context): void { + // Load scripts for sidebar. + $context->registerEventListener( + LoadAdditionalScriptsEvent::class, + LoadAdditionalScriptsListener::class + ); + } + + public function boot(IBootContext $context): void { + } +} diff --git a/lib/Listener/LoadAdditionalScriptsListener.php b/lib/Listener/LoadAdditionalScriptsListener.php new file mode 100644 index 0000000..12afac7 --- /dev/null +++ b/lib/Listener/LoadAdditionalScriptsListener.php @@ -0,0 +1,41 @@ + + * + * @author Richard Steinmetz + * + * 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\Printer\Listener; + +use OCA\Files\Event\LoadAdditionalScriptsEvent; +use OCP\EventDispatcher\Event; +use OCP\EventDispatcher\IEventListener; +use OCP\Util; + +class LoadAdditionalScriptsListener implements IEventListener { + + public function handle(Event $event): void { + if (!($event instanceof LoadAdditionalScriptsEvent)) { + return; + } + + Util::addScript('printer', 'printer.tabview'); + Util::addScript('printer', 'printer.plugin'); + } +}