Browse Source
chore: Move comments event handler to use proper event dispatcher
chore: Move comments event handler to use proper event dispatcher
Signed-off-by: Julius Härtl <jus@bitgrid.net>pull/45951/head
No known key found for this signature in database
GPG Key ID: 4C614C6ED2CDE6DF
8 changed files with 36 additions and 26 deletions
-
2apps/comments/composer/composer/autoload_classmap.php
-
2apps/comments/composer/composer/autoload_static.php
-
19apps/comments/lib/AppInfo/Application.php
-
24apps/comments/lib/Listener/CommentsEventListener.php
-
6apps/comments/tests/Unit/EventHandlerTest.php
-
3lib/private/Comments/Manager.php
-
2lib/public/Comments/ICommentsEventHandler.php
-
4tests/lib/Comments/ManagerTest.php
@ -1,28 +1,34 @@ |
|||||
<?php |
<?php |
||||
|
|
||||
|
declare(strict_types=1); |
||||
|
|
||||
/** |
/** |
||||
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors |
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors |
||||
* SPDX-License-Identifier: AGPL-3.0-or-later |
* SPDX-License-Identifier: AGPL-3.0-or-later |
||||
*/ |
*/ |
||||
namespace OCA\Comments; |
|
||||
|
|
||||
|
|
||||
|
namespace OCA\Comments\Listener; |
||||
|
|
||||
use OCA\Comments\Activity\Listener as ActivityListener; |
use OCA\Comments\Activity\Listener as ActivityListener; |
||||
use OCA\Comments\Notification\Listener as NotificationListener; |
use OCA\Comments\Notification\Listener as NotificationListener; |
||||
use OCP\Comments\CommentsEvent; |
use OCP\Comments\CommentsEvent; |
||||
use OCP\Comments\ICommentsEventHandler; |
|
||||
|
use OCP\EventDispatcher\Event; |
||||
|
use OCP\EventDispatcher\IEventListener; |
||||
|
|
||||
/** |
|
||||
* Class EventHandler |
|
||||
* |
|
||||
* @package OCA\Comments |
|
||||
*/ |
|
||||
class EventHandler implements ICommentsEventHandler { |
|
||||
|
/** @template-implements IEventListener<CommentsEvent|Event> */ |
||||
|
class CommentsEventListener implements IEventListener { |
||||
public function __construct( |
public function __construct( |
||||
private ActivityListener $activityListener, |
private ActivityListener $activityListener, |
||||
private NotificationListener $notificationListener, |
private NotificationListener $notificationListener, |
||||
) { |
) { |
||||
} |
} |
||||
|
|
||||
public function handle(CommentsEvent $event): void { |
|
||||
|
public function handle(Event $event): void { |
||||
|
if (!$event instanceof CommentsEvent) { |
||||
|
return; |
||||
|
} |
||||
|
|
||||
if ($event->getComment()->getObjectType() !== 'files') { |
if ($event->getComment()->getObjectType() !== 'files') { |
||||
// this is a 'files'-specific Handler
|
// this is a 'files'-specific Handler
|
||||
return; |
return; |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue