Skip to content

Commit

Permalink
Fix app for Nextcloud 20
Browse files Browse the repository at this point in the history
  • Loading branch information
e-alfred committed Dec 16, 2020
1 parent bcaca44 commit 0049707
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 14 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Checksum
Printer
========

**App for [Nextcloud](https://nextcloud.com) to print files using the CUPS/LPR printing ecosystem.**
Expand Down
12 changes: 0 additions & 12 deletions appinfo/app.php

This file was deleted.

2 changes: 1 addition & 1 deletion appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@
<bugs>https://github.com/e-alfred/nextcloud-printer/issues</bugs>
<screenshot>https://github.com/e-alfred/nextcloud-printer/raw/master/screenshots/printer.gif</screenshot>
<dependencies>
<nextcloud min-version="16" max-version="19" />
<nextcloud min-version="18" max-version="20" />
</dependencies>
</info>
50 changes: 50 additions & 0 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

declare(strict_types=1);

/**
* @copyright Copyright (C) 2020 Richard Steinmetz <[email protected]>
*
* @author Richard Steinmetz <[email protected]>
*
* 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 <https://www.gnu.org/licenses/>.
*/

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 {
}
}
41 changes: 41 additions & 0 deletions lib/Listener/LoadAdditionalScriptsListener.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

declare(strict_types=1);

/**
* @copyright Copyright (C) 2020 Richard Steinmetz <[email protected]>
*
* @author Richard Steinmetz <[email protected]>
*
* 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 <https://www.gnu.org/licenses/>.
*/

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');
}
}

0 comments on commit 0049707

Please sign in to comment.