diff options
Diffstat (limited to 'lib/private/Share20/Manager.php')
-rw-r--r-- | lib/private/Share20/Manager.php | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php index 42db0d8af5d..4c94cf26a4d 100644 --- a/lib/private/Share20/Manager.php +++ b/lib/private/Share20/Manager.php @@ -44,6 +44,7 @@ use OC\Cache\CappedMemoryCache; use OC\Files\Mount\MoveableMount; use OC\HintException; use OC\Share20\Exception\ProviderException; +use OCP\EventDispatcher\IEventDispatcher; use OCP\Files\File; use OCP\Files\Folder; use OCP\Files\IRootFolder; @@ -101,7 +102,7 @@ class Manager implements IManager { /** @var CappedMemoryCache */ private $sharingDisabledForUsersCache; /** @var EventDispatcherInterface */ - private $eventDispatcher; + private $legacyDispatcher; /** @var LegacyHooks */ private $legacyHooks; /** @var IMailer */ @@ -110,6 +111,8 @@ class Manager implements IManager { private $urlGenerator; /** @var \OC_Defaults */ private $defaults; + /** @var IEventDispatcher */ + private $dispatcher; /** @@ -143,10 +146,11 @@ class Manager implements IManager { IProviderFactory $factory, IUserManager $userManager, IRootFolder $rootFolder, - EventDispatcherInterface $eventDispatcher, + EventDispatcherInterface $legacyDispatcher, IMailer $mailer, IURLGenerator $urlGenerator, - \OC_Defaults $defaults + \OC_Defaults $defaults, + IEventDispatcher $dispatcher ) { $this->logger = $logger; $this->config = $config; @@ -159,12 +163,13 @@ class Manager implements IManager { $this->factory = $factory; $this->userManager = $userManager; $this->rootFolder = $rootFolder; - $this->eventDispatcher = $eventDispatcher; + $this->legacyDispatcher = $legacyDispatcher; $this->sharingDisabledForUsersCache = new CappedMemoryCache(); - $this->legacyHooks = new LegacyHooks($this->eventDispatcher); + $this->legacyHooks = new LegacyHooks($this->legacyDispatcher); $this->mailer = $mailer; $this->urlGenerator = $urlGenerator; $this->defaults = $defaults; + $this->dispatcher = $dispatcher; } /** @@ -195,7 +200,7 @@ class Manager implements IManager { // Let others verify the password try { - $this->eventDispatcher->dispatch(new ValidatePasswordPolicyEvent($password)); + $this->legacyDispatcher->dispatch(new ValidatePasswordPolicyEvent($password)); } catch (HintException $e) { throw new \Exception($e->getHint()); } @@ -766,7 +771,7 @@ class Manager implements IManager { // Pre share event $event = new GenericEvent($share); - $this->eventDispatcher->dispatch('OCP\Share::preShare', $event); + $this->legacyDispatcher->dispatch('OCP\Share::preShare', $event); if ($event->isPropagationStopped() && $event->hasArgument('error')) { throw new \Exception($event->getArgument('error')); } @@ -779,7 +784,9 @@ class Manager implements IManager { // Post share event $event = new GenericEvent($share); - $this->eventDispatcher->dispatch('OCP\Share::postShare', $event); + $this->legacyDispatcher->dispatch('OCP\Share::postShare', $event); + + $this->dispatcher->dispatchTyped(new Share\Events\ShareCreatedEvent($share)); if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) { $mailSend = $share->getMailSend(); @@ -1041,7 +1048,7 @@ class Manager implements IManager { } $provider->acceptShare($share, $recipientId); $event = new GenericEvent($share); - $this->eventDispatcher->dispatch('OCP\Share::postAcceptShare', $event); + $this->legacyDispatcher->dispatch('OCP\Share::postAcceptShare', $event); return $share; } @@ -1111,7 +1118,7 @@ class Manager implements IManager { } $event = new GenericEvent($share); - $this->eventDispatcher->dispatch('OCP\Share::preUnshare', $event); + $this->legacyDispatcher->dispatch('OCP\Share::preUnshare', $event); // Get all children and delete them as well $deletedShares = $this->deleteChildren($share); @@ -1125,7 +1132,7 @@ class Manager implements IManager { // Emit post hook $event->setArgument('deletedShares', $deletedShares); - $this->eventDispatcher->dispatch('OCP\Share::postUnshare', $event); + $this->legacyDispatcher->dispatch('OCP\Share::postUnshare', $event); } @@ -1144,7 +1151,7 @@ class Manager implements IManager { $provider->deleteFromSelf($share, $recipientId); $event = new GenericEvent($share); - $this->eventDispatcher->dispatch('OCP\Share::postUnshareFromSelf', $event); + $this->legacyDispatcher->dispatch('OCP\Share::postUnshareFromSelf', $event); } public function restoreShare(IShare $share, string $recipientId): IShare { |