diff options
author | Joas Schilling <coding@schilljs.com> | 2023-07-27 21:45:31 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2023-07-28 14:11:19 +0200 |
commit | 44b810bfbd83fc6eb95a67430894dbd2cf6eb339 (patch) | |
tree | bebee497a72c8cc05dc171503211888c97184f69 /lib/private/Share20/Manager.php | |
parent | 68fc9b48c24bf810488c5910da2feadd10587e51 (diff) | |
download | nextcloud-server-44b810bfbd83fc6eb95a67430894dbd2cf6eb339.tar.gz nextcloud-server-44b810bfbd83fc6eb95a67430894dbd2cf6eb339.zip |
feat!: Migrate Sharing events to typed events
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/private/Share20/Manager.php')
-rw-r--r-- | lib/private/Share20/Manager.php | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php index 3f5dbd7cd28..9799d145a48 100644 --- a/lib/private/Share20/Manager.php +++ b/lib/private/Share20/Manager.php @@ -67,6 +67,7 @@ use OCP\Security\Events\ValidatePasswordPolicyEvent; use OCP\Security\IHasher; use OCP\Security\ISecureRandom; use OCP\Share; +use OCP\Share\Events\ShareCreatedEvent; use OCP\Share\Exceptions\AlreadySharedException; use OCP\Share\Exceptions\GenericShareException; use OCP\Share\Exceptions\ShareNotFound; @@ -806,10 +807,10 @@ class Manager implements IManager { $share->setTarget($target); // Pre share event - $event = new GenericEvent($share); - $this->legacyDispatcher->dispatch('OCP\Share::preShare', $event); - if ($event->isPropagationStopped() && $event->hasArgument('error')) { - throw new \Exception($event->getArgument('error')); + $event = new Share\Events\BeforeShareCreatedEvent($share); + $this->dispatcher->dispatchTyped($event); + if ($event->isPropagationStopped() && $event->getError()) { + throw new \Exception($event->getError()); } $oldShare = $share; @@ -833,10 +834,7 @@ class Manager implements IManager { } // Post share event - $event = new GenericEvent($share); - $this->legacyDispatcher->dispatch('OCP\Share::postShare', $event); - - $this->dispatcher->dispatchTyped(new Share\Events\ShareCreatedEvent($share)); + $this->dispatcher->dispatchTyped(new ShareCreatedEvent($share)); if ($this->config->getSystemValueBool('sharing.enable_share_mail', true) && $share->getShareType() === IShare::TYPE_USER) { |