Skip to content

Commit

Permalink
fix: avoid deprecated methods
Browse files Browse the repository at this point in the history
Signed-off-by: Arthur Schiwon <[email protected]>
  • Loading branch information
blizzz committed Jul 24, 2024
1 parent e543afd commit ca491c6
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 26 deletions.
20 changes: 4 additions & 16 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);
/**
* @copyright Copyright (c) 2020 Arthur Schiwon <[email protected]>
* @copyright Copyright (c) 2024 Arthur Schiwon <[email protected]>
*
* @author Arthur Schiwon <[email protected]>
*
Expand All @@ -25,15 +25,12 @@

namespace OCA\FlowNotifications\AppInfo;

use OCA\FlowNotifications\Flow\Operation;
use OCA\FlowNotifications\Listener\RegisterOperationsListener;
use OCA\FlowNotifications\Notification\Notifier;
use OCP\AppFramework\App;
use OCP\AppFramework\Bootstrap\IBootContext;
use OCP\AppFramework\Bootstrap\IBootstrap;
use OCP\AppFramework\Bootstrap\IRegistrationContext;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Notification\IManager;
use OCP\Util;
use OCP\WorkflowEngine\Events\RegisterOperationsEvent;

class Application extends App implements IBootstrap {
Expand All @@ -44,19 +41,10 @@ public function __construct() {
}

public function register(IRegistrationContext $context): void {
$context->registerNotifierService(Notifier::class);
$context->registerEventListener(RegisterOperationsEvent::class, RegisterOperationsListener::class);
}

public function boot(IBootContext $context): void {
$container = $context->getServerContainer();
$container->get(IManager::class)->registerNotifierService(Notifier::class);

$dispatcher = $container->get(IEventDispatcher::class);
$dispatcher->addListener(RegisterOperationsEvent::class,
function (RegisterOperationsEvent $event) use ($container) {
$operation = $container->get(Operation::class);
$event->registerOperation($operation);
Util::addScript(self::APP_ID, 'flow_notifications-main');
}
);
}
}
12 changes: 6 additions & 6 deletions lib/Flow/Operation.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);
/**
* @copyright Copyright (c) 2020 Arthur Schiwon <[email protected]>
* @copyright Copyright (c) 2024 Arthur Schiwon <[email protected]>
*
* @author Arthur Schiwon <[email protected]>
*
Expand Down Expand Up @@ -45,11 +45,11 @@

class Operation implements IOperation {
public function __construct(
private IL10N $l,
private IURLGenerator $urlGenerator,
private IManager $notificationManager,
private IUserSession $userSession,
private LoggerInterface $logger,
private readonly IL10N $l,
private readonly IURLGenerator $urlGenerator,
private readonly IManager $notificationManager,
private readonly IUserSession $userSession,
private readonly LoggerInterface $logger,
) {
}

Expand Down
49 changes: 49 additions & 0 deletions lib/Listener/RegisterOperationsListener.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

declare(strict_types=1);
/**
* @copyright Copyright (c) 2024 Arthur Schiwon <[email protected]>
*
* @author Arthur Schiwon <[email protected]>
*
* @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\FlowNotifications\Listener;

use OCA\FlowNotifications\AppInfo\Application;
use OCA\FlowNotifications\Flow\Operation;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
use OCP\Util;
use OCP\WorkflowEngine\Events\RegisterOperationsEvent;

class RegisterOperationsListener implements IEventListener {

Check failure on line 35 in lib/Listener/RegisterOperationsListener.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

MissingTemplateParam

lib/Listener/RegisterOperationsListener.php:35:45: MissingTemplateParam: OCA\FlowNotifications\Listener\RegisterOperationsListener has missing template params when extending OCP\EventDispatcher\IEventListener, expecting 1 (see https://psalm.dev/182)
public function __construct(
protected readonly Operation $operation
) {
}

public function handle(Event $event): void {
if (!$event instanceof RegisterOperationsEvent) {
return;
}

$event->registerOperation($this->operation);
Util::addScript(Application::APP_ID, 'flow_notifications-main');
}
}
8 changes: 4 additions & 4 deletions lib/Notification/Notifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);
/**
* @copyright Copyright (c) 2020 Arthur Schiwon <[email protected]>
* @copyright Copyright (c) 2024 Arthur Schiwon <[email protected]>
*
* @author Arthur Schiwon <[email protected]>
*
Expand Down Expand Up @@ -41,9 +41,9 @@
class Notifier implements INotifier {

public function __construct(
private IL10N $l,
private IURLGenerator $urlGenerator,
private ContainerInterface $container,
private readonly IL10N $l,
private readonly IURLGenerator $urlGenerator,
private readonly ContainerInterface $container,
) {
}

Expand Down

0 comments on commit ca491c6

Please sign in to comment.