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
This commit is contained in:
Morris Jobke 2020-08-18 21:29:48 +02:00 committed by GitHub
commit 5ced155032
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 13 deletions

View File

@ -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();

View File

@ -81,7 +81,7 @@ class BackupCodeStorage {
$result[] = $code;
}
$this->eventDispatcher->dispatch(CodesGenerated::class, new CodesGenerated($user));
$this->eventDispatcher->dispatchTyped(new CodesGenerated($user));
return $result;
}

View File

@ -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))
);

View File

@ -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>