summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2020-08-18 21:29:48 +0200
committerGitHub <noreply@github.com>2020-08-18 21:29:48 +0200
commit5ced155032c51a90b8a9ffb6b1159a34c29194ef (patch)
tree64a523806bf2f16f90c7e3cb8a3e7e31cfb2e46c
parent5d8242c7b69641d9d73db21dc84b7e2f850515df (diff)
parenta5853d7ecc08e048144ad1e9f1ff6f1fbf192a92 (diff)
downloadnextcloud-server-5ced155032c51a90b8a9ffb6b1159a34c29194ef.tar.gz
nextcloud-server-5ced155032c51a90b8a9ffb6b1159a34c29194ef.zip
Merge pull request #22285 from nextcloud/techdebt/noid/move-to-typed-event-in-list.php
Use dispatchTyped instead of dispatch on the new event dispatcher
-rw-r--r--apps/files_sharing/list.php12
-rw-r--r--apps/twofactor_backupcodes/lib/Service/BackupCodeStorage.php2
-rw-r--r--apps/twofactor_backupcodes/tests/Unit/Service/BackupCodeStorageTest.php3
-rw-r--r--build/psalm-baseline.xml7
4 files changed, 11 insertions, 13 deletions
diff --git a/apps/files_sharing/list.php b/apps/files_sharing/list.php
index 370ca53c6b4..58d2b56b253 100644
--- a/apps/files_sharing/list.php
+++ b/apps/files_sharing/list.php
@@ -30,7 +30,9 @@ use OCP\EventDispatcher\GenericEvent;
OCP\User::checkLoggedIn();
$config = \OC::$server->getConfig();
$userSession = \OC::$server->getUserSession();
-$eventDispatcher = \OC::$server->getEventDispatcher();
+$legacyEventDispatcher = \OC::$server->getEventDispatcher();
+/** @var \OCP\EventDispatcher\IEventDispatcher $eventDispatcher */
+$eventDispatcher = \OC::$server->get(OCP\EventDispatcher\IEventDispatcher::class);
$showgridview = $config->getUserValue($userSession->getUser()->getUID(), 'files', 'show_grid', false);
$isIE = \OCP\Util::isIE();
@@ -41,13 +43,13 @@ $tmpl = new OCP\Template('files_sharing', 'list', '');
$tmpl->assign('showgridview', $showgridview && !$isIE);
// fire script events
-$eventDispatcher->dispatch('\OCP\Collaboration\Resources::loadAdditionalScripts', new GenericEvent());
-$eventDispatcher->dispatch(LoadAdditionalScriptsEvent::class, new LoadAdditionalScriptsEvent());
-$eventDispatcher->dispatch(LoadSidebar::class, new LoadSidebar());
+$legacyEventDispatcher->dispatch('\OCP\Collaboration\Resources::loadAdditionalScripts', new GenericEvent());
+$eventDispatcher->dispatchTyped(new LoadAdditionalScriptsEvent());
+$eventDispatcher->dispatchTyped(new LoadSidebar());
// Load Viewer scripts
if (class_exists(LoadViewer::class)) {
- $eventDispatcher->dispatch(LoadViewer::class, new LoadViewer());
+ $eventDispatcher->dispatchTyped(new LoadViewer());
}
$tmpl->printPage();
diff --git a/apps/twofactor_backupcodes/lib/Service/BackupCodeStorage.php b/apps/twofactor_backupcodes/lib/Service/BackupCodeStorage.php
index fb604d80aab..d85e00c0a8c 100644
--- a/apps/twofactor_backupcodes/lib/Service/BackupCodeStorage.php
+++ b/apps/twofactor_backupcodes/lib/Service/BackupCodeStorage.php
@@ -81,7 +81,7 @@ class BackupCodeStorage {
$result[] = $code;
}
- $this->eventDispatcher->dispatch(CodesGenerated::class, new CodesGenerated($user));
+ $this->eventDispatcher->dispatchTyped(new CodesGenerated($user));
return $result;
}
diff --git a/apps/twofactor_backupcodes/tests/Unit/Service/BackupCodeStorageTest.php b/apps/twofactor_backupcodes/tests/Unit/Service/BackupCodeStorageTest.php
index ef17459cb06..7d06995269c 100644
--- a/apps/twofactor_backupcodes/tests/Unit/Service/BackupCodeStorageTest.php
+++ b/apps/twofactor_backupcodes/tests/Unit/Service/BackupCodeStorageTest.php
@@ -82,9 +82,8 @@ class BackupCodeStorageTest extends TestCase {
->method('insert')
->with($this->equalTo($row));
$this->eventDispatcher->expects($this->once())
- ->method('dispatch')
+ ->method('dispatchTyped')
->with(
- $this->equalTo(CodesGenerated::class),
$this->equalTo(new CodesGenerated($user))
);
diff --git a/build/psalm-baseline.xml b/build/psalm-baseline.xml
index a3ea08ee01c..cf9f21d0918 100644
--- a/build/psalm-baseline.xml
+++ b/build/psalm-baseline.xml
@@ -1941,13 +1941,10 @@
</UndefinedMethod>
</file>
<file src="apps/files_sharing/list.php">
- <InvalidArgument occurrences="4">
+ <InvalidArgument occurrences="1">
<code>'\OCP\Collaboration\Resources::loadAdditionalScripts'</code>
- <code>LoadAdditionalScriptsEvent::class</code>
- <code>LoadSidebar::class</code>
- <code>LoadViewer::class</code>
</InvalidArgument>
- <TooManyArguments occurrences="4">
+ <TooManyArguments occurrences="1">
<code>dispatch</code>
<code>dispatch</code>
<code>dispatch</code>