Skip to content

Commit

Permalink
Fix event dispatch calls for Symfony
Browse files Browse the repository at this point in the history
  • Loading branch information
phil-davis committed Jan 13, 2023
1 parent 676bae8 commit 0104b0c
Show file tree
Hide file tree
Showing 17 changed files with 58 additions and 58 deletions.
2 changes: 1 addition & 1 deletion apps/comments/lib/Dav/RootCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ protected function initCollections() {
}

$event = new CommentsEntityEvent(CommentsEntityEvent::EVENT_ENTITY);
$this->dispatcher->dispatch(CommentsEntityEvent::EVENT_ENTITY, $event);
$this->dispatcher->dispatch($event, CommentsEntityEvent::EVENT_ENTITY);

$this->entityTypeCollections = [];
foreach ($event->getEntityCollections() as $entity => $entityExistsFunction) {
Expand Down
2 changes: 1 addition & 1 deletion apps/dav/appinfo/v1/webdav.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@

// allow setup of additional auth backends
$event = new \OCP\SabrePluginEvent($server);
\OC::$server->getEventDispatcher()->dispatch('OCA\DAV\Connector\Sabre::authInit', $event);
\OC::$server->getEventDispatcher()->dispatch($event, 'OCA\DAV\Connector\Sabre::authInit');

\Sabre\DAV\Server::$streamMultiStatus = true;
// And off we go!
Expand Down
12 changes: 6 additions & 6 deletions apps/dav/lib/CardDAV/CardDavBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -552,11 +552,11 @@ public function createCard($addressBookId, $cardUri, $cardData) {

if ($this->dispatcher !== null) {
$this->dispatcher->dispatch(
'\OCA\DAV\CardDAV\CardDavBackend::createCard',
new GenericEvent(null, [
'addressBookId' => $addressBookId,
'cardUri' => $cardUri,
'cardData' => $cardData])
'cardData' => $cardData]),
'\OCA\DAV\CardDAV\CardDavBackend::createCard',
);
}

Expand Down Expand Up @@ -605,11 +605,11 @@ public function updateCard($addressBookId, $cardUri, $cardData) {

if ($this->dispatcher !== null) {
$this->dispatcher->dispatch(
'\OCA\DAV\CardDAV\CardDavBackend::updateCard',
new GenericEvent(null, [
'addressBookId' => $addressBookId,
'cardUri' => $cardUri,
'cardData' => $cardData])
'cardData' => $cardData]),
'\OCA\DAV\CardDAV\CardDavBackend::updateCard'
);
}

Expand Down Expand Up @@ -639,10 +639,10 @@ public function deleteCard($addressBookId, $cardUri) {

if ($this->dispatcher !== null) {
$this->dispatcher->dispatch(
'\OCA\DAV\CardDAV\CardDavBackend::deleteCard',
new GenericEvent(null, [
'addressBookId' => $addressBookId,
'cardUri' => $cardUri])
'cardUri' => $cardUri]),
'\OCA\DAV\CardDAV\CardDavBackend::deleteCard'
);
}

Expand Down
22 changes: 11 additions & 11 deletions apps/dav/lib/Connector/Sabre/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,10 @@ public function put($data) {
$path = $this->fileView->getAbsolutePath($this->path);
$beforeEvent = new GenericEvent(null, ['path' => $path]);
if (!$this->fileView->file_exists($this->path)) {
\OC::$server->getEventDispatcher()->dispatch('file.beforecreate', $beforeEvent);
\OC::$server->getEventDispatcher()->dispatch($beforeEvent, 'file.beforecreate');
$newFile = true;
} else {
\OC::$server->getEventDispatcher()->dispatch('file.beforeupdate', $beforeEvent);
\OC::$server->getEventDispatcher()->dispatch($beforeEvent, 'file.beforeupdate');
}

list($partStorage) = $this->fileView->resolvePath($this->path);
Expand Down Expand Up @@ -311,9 +311,9 @@ public function put($data) {

$afterEvent = new GenericEvent(null, ['path' => $path]);
if ($newFile === true) {
\OC::$server->getEventDispatcher()->dispatch('file.aftercreate', $afterEvent);
\OC::$server->getEventDispatcher()->dispatch($afterEvent, 'file.aftercreate');
} else {
\OC::$server->getEventDispatcher()->dispatch('file.afterupdate', $afterEvent);
\OC::$server->getEventDispatcher()->dispatch($afterEvent, 'file.afterupdate');
}
return '"' . $this->info->getEtag() . '"';
}
Expand Down Expand Up @@ -365,7 +365,7 @@ private function emitPreHooks($exists, $path = null) {
]);
if ($run) {
$event->setArgument('run', $run);
\OC::$server->getEventDispatcher()->dispatch('file.beforeCreate', $event);
\OC::$server->getEventDispatcher()->dispatch($event, 'file.beforeCreate');
$run = $event->getArgument('run');
}
} else {
Expand All @@ -375,7 +375,7 @@ private function emitPreHooks($exists, $path = null) {
]);
if ($run) {
$event->setArgument('run', $run);
\OC::$server->getEventDispatcher()->dispatch('file.beforeUpdate', $event);
\OC::$server->getEventDispatcher()->dispatch($event, 'file.beforeUpdate');
$run = $event->getArgument('run');
}
}
Expand All @@ -385,7 +385,7 @@ private function emitPreHooks($exists, $path = null) {
]);
if ($run) {
$event->setArgument('run', $run);
\OC::$server->getEventDispatcher()->dispatch('file.beforeWrite', $event);
\OC::$server->getEventDispatcher()->dispatch($event, 'file.beforeWrite');
$run = $event->getArgument('run');
}
return $run;
Expand Down Expand Up @@ -545,10 +545,10 @@ private function createFileChunked($data) {
$beforeEvent = new GenericEvent(null, ['path' => $absPath]);
$newFile = false;
if (!$this->fileView->file_exists($targetPath)) {
\OC::$server->getEventDispatcher()->dispatch('file.beforecreate', $beforeEvent);
\OC::$server->getEventDispatcher()->dispatch($beforeEvent, 'file.beforecreate');
$newFile = true;
} else {
\OC::$server->getEventDispatcher()->dispatch('file.beforeupdate', $beforeEvent);
\OC::$server->getEventDispatcher()->dispatch($beforeEvent, 'file.beforeupdate');
}

/** @var \OC\Files\Storage\Storage $targetStorage */
Expand Down Expand Up @@ -626,9 +626,9 @@ private function createFileChunked($data) {
if ($etag !== null) {
$afterEvent = new GenericEvent(null, ['path' => $absPath]);
if ($newFile === true) {
\OC::$server->getEventDispatcher()->dispatch('file.aftercreate', $afterEvent);
\OC::$server->getEventDispatcher()->dispatch($afterEvent, 'file.aftercreate');
} else {
\OC::$server->getEventDispatcher()->dispatch('file.afterupdate', $afterEvent);
\OC::$server->getEventDispatcher()->dispatch($afterEvent, 'file.afterupdate');
}
}
return $etag;
Expand Down
4 changes: 2 additions & 2 deletions apps/dav/lib/Files/Sharing/PublicLinkEventsPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function beforeMethod(RequestInterface $request, ResponseInterface $respo
* dav.public.delete.before
*/
$eventName = "dav.public.{$lowercaseMethod}.before";
$this->dispatcher->dispatch($eventName, $event);
$this->dispatcher->dispatch($event, $eventName);
}

/**
Expand Down Expand Up @@ -128,6 +128,6 @@ public function afterMethod(RequestInterface $request, ResponseInterface $respon
* dav.public.delete.after
*/
$eventName = "dav.public.{$lowercaseMethod}.after";
$this->dispatcher->dispatch($eventName, $event);
$this->dispatcher->dispatch($event, $eventName);
}
}
2 changes: 1 addition & 1 deletion apps/dav/lib/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public function __construct(IRequest $request, $baseUri) {

// allow setup of additional auth backends
$event = new SabrePluginEvent($this->server);
$dispatcher->dispatch('OCA\DAV\Connector\Sabre::authInit', $event);
$dispatcher->dispatch($event, 'OCA\DAV\Connector\Sabre::authInit');

// because we are throwing exceptions this plugin has to be the last one
$authPlugin->addBackend($authBackend);
Expand Down
4 changes: 2 additions & 2 deletions apps/federatedfilesharing/lib/FedShareManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ public function createShare(
);

$this->eventDispatcher->dispatch(
'\OCA\FederatedFileSharing::remote_shareReceived',
new GenericEvent(
null,
[
Expand All @@ -154,7 +153,8 @@ public function createShare(
'sharedby' => $sharedByAddress->getUserId(),
'remoteid' => $remoteId
]
)
),
'\OCA\FederatedFileSharing::remote_shareReceived'
);
$this->publishActivity(
$shareWith,
Expand Down
8 changes: 4 additions & 4 deletions apps/federatedfilesharing/lib/FederatedShareProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ public function delete(IShare $share) {
* a message that the file was unshared
*
* @param IShare $share
* @param bool $isOwner the user can either be the owner or the user who re-sahred it
* @param bool $isOwner the user can either be the owner or the user who re-shared it
* @throws ShareNotFound
* @throws \OC\HintException
*/
Expand Down Expand Up @@ -921,7 +921,7 @@ private function getRawShare($id) {
}

/**
* Create a share object from an database row
* Create a share object from a database row
*
* @param array $data
* @return IShare
Expand Down Expand Up @@ -1153,8 +1153,8 @@ public function addShare($remote, $token, $name, $owner, $shareWith, $remoteId)
*/
public function getAccepted($remote, $shareWith) {
$event = $this->eventDispatcher->dispatch(
'remoteshare.received',
new GenericEvent('', ['remote' => $remote])
new GenericEvent('', ['remote' => $remote]),
'remoteshare.received'
);
'@phan-var GenericEvent $event';
if ($event->getArgument('autoAddServers')) {
Expand Down
2 changes: 1 addition & 1 deletion apps/federation/lib/TrustedServers.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public function removeServer($id) {
$server = $this->dbHandler->getServerById($id);
$this->dbHandler->removeServer($id);
$event = new GenericEvent($server['url_hash']);
$this->dispatcher->dispatch('OCP\Federation\TrustedServerEvent::remove', $event);
$this->dispatcher->dispatch($event, 'OCP\Federation\TrustedServerEvent::remove');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion apps/files/download.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

//Dispatch an event to see if any apps have problem with download
$event = new \Symfony\Component\EventDispatcher\GenericEvent(null, ['path' => $filename]);
OC::$server->getEventDispatcher()->dispatch('file.beforeGetDirect', $event);
OC::$server->getEventDispatcher()->dispatch($event, 'file.beforeGetDirect');
if ($event->hasArgument('errorMessage')) {
\http_response_code(403);
$tmpl = new OCP\Template('', '403', 'guest');
Expand Down
2 changes: 1 addition & 1 deletion apps/files/lib/Controller/ViewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ public function showFile($fileId, $details = null) {
'resolvedWebLink' => null,
'resolvedDavLink' => null,
]);
$this->eventDispatcher->dispatch('files.resolvePrivateLink', $event);
$this->eventDispatcher->dispatch($event, 'files.resolvePrivateLink');

$webUrl = $event->getArgument('resolvedWebLink');
$webdavUrl = $event->getArgument('resolvedDavLink');
Expand Down
12 changes: 6 additions & 6 deletions apps/files_sharing/lib/Controller/Share20OcsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ protected function formatShare(IShare $share, $received = false) {
$result['share_with_displayname'] = $group !== null ? $group->getDisplayName() : $share->getSharedWith();
} elseif ($share->getShareType() === Share::SHARE_TYPE_LINK) {
if ($share->getPassword() !== null) {
// Misleading names ahead!: This fields are miss-used to
// Misleading names ahead!: These fields are miss-used to
// read/write public link password-hashes
$result['share_with'] = '***redacted***';
$result['share_with_displayname'] = '***redacted***';
Expand Down Expand Up @@ -307,7 +307,7 @@ public function getShare($id) {
$share = $this->formatShare($share);
return new Result([$share]);
} catch (NotFoundException $e) {
//Fall trough
//Fall through
} catch (StorageNotAvailableException $e) {
// could happen if the share node points to a storage which isn't available
// TODO: This should go through an injected logger instance
Expand Down Expand Up @@ -453,7 +453,7 @@ public function createShare() {
return new Result(null, 404, $this->l->t('Please specify a valid user'));
}

// Fetch the UID to match exactly with the user (case sensitive).
// Fetch the UID to match exactly with the user (case-sensitive).
$share->setSharedWith($user->getUID());
$share->setPermissions($permissions);
if ($userAutoAccept) {
Expand Down Expand Up @@ -1018,7 +1018,7 @@ private function updateShareState($id, $state) {

try {
$share = $this->getShareById($id, $this->userSession->getUser()->getUID());
$this->eventDispatcher->dispatch('share.before' . $eventName, new GenericEvent(null, ['share' => $share]));
$this->eventDispatcher->dispatch(new GenericEvent(null, ['share' => $share]), 'share.before' . $eventName);
} catch (ShareNotFound $e) {
return new Result(null, 404, $this->l->t('Wrong share ID, share doesn\'t exist'));
}
Expand All @@ -1041,7 +1041,7 @@ private function updateShareState($id, $state) {

if ($share->getState() === $state) {
if ($eventName !== '') {
$this->eventDispatcher->dispatch('share.after' . $eventName, new GenericEvent(null, ['share' => $share]));
$this->eventDispatcher->dispatch(new GenericEvent(null, ['share' => $share]), 'share.after' . $eventName);
}
// if there are no changes in the state, just return the share as if the change was successful
$node->unlock(ILockingProvider::LOCK_SHARED);
Expand Down Expand Up @@ -1084,7 +1084,7 @@ private function updateShareState($id, $state) {
$this->notificationPublisher->discardNotificationForUser($share, $this->userSession->getUser()->getUID());

if ($eventName !== '') {
$this->eventDispatcher->dispatch('share.after' . $eventName, new GenericEvent(null, ['share' => $share]));
$this->eventDispatcher->dispatch(new GenericEvent(null, ['share' => $share]), 'share.after' . $eventName);
}
return new Result([$this->formatShare($share, true)]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public function create($id) {
'shareRecipient' => $shareInfo['user'],
]
);
$this->dispatcher->dispatch('remoteshare.accepted', $event);
$this->dispatcher->dispatch($event, 'remoteshare.accepted');
$this->externalManager->acceptShare($id);
}
return new JSONResponse();
Expand All @@ -130,7 +130,7 @@ public function destroy($id) {
'remoteUrl' => $shareInfo['remote']
]
);
$this->dispatcher->dispatch('remoteshare.declined', $event);
$this->dispatcher->dispatch($event, 'remoteshare.declined');
$this->externalManager->declineShare($id);
}
return new JSONResponse();
Expand Down
6 changes: 3 additions & 3 deletions apps/files_sharing/lib/Controllers/ShareController.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public function authenticate($token, $password = '') {
*/
private function linkShareAuth(\OCP\Share\IShare $share, $password = null) {
$beforeEvent = new GenericEvent(null, ['shareObject' => $share]);
$this->eventDispatcher->dispatch('share.beforelinkauth', $beforeEvent);
$this->eventDispatcher->dispatch($beforeEvent, 'share.beforelinkauth');
if ($password !== null) {
if ($this->shareManager->checkPassword($share, $password)) {
$this->session->set('public_link_authenticated', (string)$share->getId());
Expand All @@ -208,7 +208,7 @@ private function linkShareAuth(\OCP\Share\IShare $share, $password = null) {
}
}
$afterEvent = new GenericEvent(null, ['shareObject' => $share]);
$this->eventDispatcher->dispatch('share.afterlinkauth', $afterEvent);
$this->eventDispatcher->dispatch($afterEvent, 'share.afterlinkauth');
return true;
}

Expand Down Expand Up @@ -253,7 +253,7 @@ protected function emitAccessShareHook($share, $errorCode = 200, $errorMessage =
['shareObject' => $cloneShare, 'errorCode' => $errorCode,
'errorMessage' => $errorMessage]
);
$this->eventDispatcher->dispatch('share.linkaccess', $publicShareLinkAccessEvent);
$this->eventDispatcher->dispatch($publicShareLinkAccessEvent, 'share.linkaccess');
}

if ($exception !== null) {
Expand Down
Loading

0 comments on commit 0104b0c

Please sign in to comment.