summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorJoas Schilling <213943+nickvergessen@users.noreply.github.com>2023-07-19 17:25:57 +0200
committerGitHub <noreply@github.com>2023-07-19 17:25:57 +0200
commit489b4807dbc52e69590846ff76d0d4d5b4ab2968 (patch)
tree723050e0fd96b3bef2338ca40c359b1548a2cc1d /apps
parent8b3b5ff8d86613c2f9c85ff5c9c5441a451961b8 (diff)
parentc3bc575d992c6816a89bb18734146c67ecdd17d2 (diff)
downloadnextcloud-server-489b4807dbc52e69590846ff76d0d4d5b4ab2968.tar.gz
nextcloud-server-489b4807dbc52e69590846ff76d0d4d5b4ab2968.zip
Merge pull request #39304 from nextcloud/bugfix/noid/typed-event-comments-entity
fix(comments): Emit CommentsEntityEvent as typed event
Diffstat (limited to 'apps')
-rw-r--r--apps/comments/lib/AppInfo/Application.php2
-rw-r--r--apps/dav/lib/Comments/RootCollection.php9
-rw-r--r--apps/dav/lib/RootCollection.php2
-rw-r--r--apps/dav/tests/unit/Comments/RootCollectionTest.php16
4 files changed, 13 insertions, 16 deletions
diff --git a/apps/comments/lib/AppInfo/Application.php b/apps/comments/lib/AppInfo/Application.php
index bfd66c43ecd..db147970a64 100644
--- a/apps/comments/lib/AppInfo/Application.php
+++ b/apps/comments/lib/AppInfo/Application.php
@@ -66,7 +66,7 @@ class Application extends App implements IBootstrap {
LoadSidebarScripts::class
);
$context->registerEventListener(
- CommentsEntityEvent::EVENT_ENTITY,
+ CommentsEntityEvent::class,
CommentsEntityEventListener::class
);
$context->registerSearchProvider(CommentsSearchProvider::class);
diff --git a/apps/dav/lib/Comments/RootCollection.php b/apps/dav/lib/Comments/RootCollection.php
index 39d644b4766..956980c900d 100644
--- a/apps/dav/lib/Comments/RootCollection.php
+++ b/apps/dav/lib/Comments/RootCollection.php
@@ -26,6 +26,7 @@ namespace OCA\DAV\Comments;
use OCP\Comments\CommentsEntityEvent;
use OCP\Comments\ICommentsManager;
+use OCP\EventDispatcher\IEventDispatcher;
use OCP\IUserManager;
use OCP\IUserSession;
use Psr\Log\LoggerInterface;
@@ -33,7 +34,6 @@ use Sabre\DAV\Exception\Forbidden;
use Sabre\DAV\Exception\NotAuthenticated;
use Sabre\DAV\Exception\NotFound;
use Sabre\DAV\ICollection;
-use Symfony\Component\EventDispatcher\EventDispatcherInterface;
class RootCollection implements ICollection {
/** @var EntityTypeCollection[]|null */
@@ -43,13 +43,13 @@ class RootCollection implements ICollection {
protected LoggerInterface $logger;
protected IUserManager $userManager;
protected IUserSession $userSession;
- protected EventDispatcherInterface $dispatcher;
+ protected IEventDispatcher $dispatcher;
public function __construct(
ICommentsManager $commentsManager,
IUserManager $userManager,
IUserSession $userSession,
- EventDispatcherInterface $dispatcher,
+ IEventDispatcher $dispatcher,
LoggerInterface $logger) {
$this->commentsManager = $commentsManager;
$this->logger = $logger;
@@ -74,7 +74,8 @@ class RootCollection implements ICollection {
throw new NotAuthenticated();
}
- $event = new CommentsEntityEvent(CommentsEntityEvent::EVENT_ENTITY);
+ $event = new CommentsEntityEvent();
+ $this->dispatcher->dispatchTyped($event);
$this->dispatcher->dispatch(CommentsEntityEvent::EVENT_ENTITY, $event);
$this->entityTypeCollections = [];
diff --git a/apps/dav/lib/RootCollection.php b/apps/dav/lib/RootCollection.php
index 80d96f0d748..e4fd814ed81 100644
--- a/apps/dav/lib/RootCollection.php
+++ b/apps/dav/lib/RootCollection.php
@@ -139,7 +139,7 @@ class RootCollection extends SimpleCollection {
\OC::$server->getCommentsManager(),
$userManager,
\OC::$server->getUserSession(),
- \OC::$server->getEventDispatcher(),
+ $dispatcher,
$logger
);
diff --git a/apps/dav/tests/unit/Comments/RootCollectionTest.php b/apps/dav/tests/unit/Comments/RootCollectionTest.php
index 8e5e4ecad7c..b985d0b08c6 100644
--- a/apps/dav/tests/unit/Comments/RootCollectionTest.php
+++ b/apps/dav/tests/unit/Comments/RootCollectionTest.php
@@ -26,15 +26,14 @@
namespace OCA\DAV\Tests\unit\Comments;
use OC\EventDispatcher\EventDispatcher;
-use OC\EventDispatcher\SymfonyAdapter;
use OCA\DAV\Comments\EntityTypeCollection as EntityTypeCollectionImplementation;
use OCP\Comments\CommentsEntityEvent;
use OCP\Comments\ICommentsManager;
+use OCP\EventDispatcher\IEventDispatcher;
use OCP\IUser;
use OCP\IUserManager;
use OCP\IUserSession;
use Psr\Log\LoggerInterface;
-use Symfony\Component\EventDispatcher\EventDispatcherInterface;
class RootCollectionTest extends \Test\TestCase {
@@ -48,7 +47,7 @@ class RootCollectionTest extends \Test\TestCase {
protected $collection;
/** @var \OCP\IUserSession|\PHPUnit\Framework\MockObject\MockObject */
protected $userSession;
- /** @var EventDispatcherInterface */
+ /** @var IEventDispatcher */
protected $dispatcher;
/** @var \OCP\IUser|\PHPUnit\Framework\MockObject\MockObject */
protected $user;
@@ -72,12 +71,9 @@ class RootCollectionTest extends \Test\TestCase {
$this->logger = $this->getMockBuilder(LoggerInterface::class)
->disableOriginalConstructor()
->getMock();
- $this->dispatcher = new SymfonyAdapter(
- new EventDispatcher(
- new \Symfony\Component\EventDispatcher\EventDispatcher(),
- \OC::$server,
- $this->logger
- ),
+ $this->dispatcher = new EventDispatcher(
+ new \Symfony\Component\EventDispatcher\EventDispatcher(),
+ \OC::$server,
$this->logger
);
@@ -99,7 +95,7 @@ class RootCollectionTest extends \Test\TestCase {
->method('getUser')
->willReturn($this->user);
- $this->dispatcher->addListener(CommentsEntityEvent::EVENT_ENTITY, function (CommentsEntityEvent $event): void {
+ $this->dispatcher->addListener(CommentsEntityEvent::class, function (CommentsEntityEvent $event): void {
$event->addEntityCollection('files', function () {
return true;
});