aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/Share20/Manager.php
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2023-07-27 22:25:26 +0200
committerJoas Schilling <coding@schilljs.com>2023-07-28 14:11:20 +0200
commit8ad94cbfda58c28dacaa391390033854abdfc8b3 (patch)
treeb6a7f2a3a986f2318335c4193e1de07564eb1d62 /lib/private/Share20/Manager.php
parent44b810bfbd83fc6eb95a67430894dbd2cf6eb339 (diff)
downloadnextcloud-server-8ad94cbfda58c28dacaa391390033854abdfc8b3.tar.gz
nextcloud-server-8ad94cbfda58c28dacaa391390033854abdfc8b3.zip
feat!: Migrate unShare 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.php25
1 files changed, 11 insertions, 14 deletions
diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php
index 9799d145a48..30c51f65145 100644
--- a/lib/private/Share20/Manager.php
+++ b/lib/private/Share20/Manager.php
@@ -67,7 +67,10 @@ use OCP\Security\Events\ValidatePasswordPolicyEvent;
use OCP\Security\IHasher;
use OCP\Security\ISecureRandom;
use OCP\Share;
+use OCP\Share\Events\BeforeShareDeletedEvent;
use OCP\Share\Events\ShareCreatedEvent;
+use OCP\Share\Events\ShareDeletedEvent;
+use OCP\Share\Events\ShareDeletedFromSelfEvent;
use OCP\Share\Exceptions\AlreadySharedException;
use OCP\Share\Exceptions\GenericShareException;
use OCP\Share\Exceptions\ShareNotFound;
@@ -1204,11 +1207,13 @@ class Manager implements IManager {
$provider = $this->factory->getProviderForType($share->getShareType());
foreach ($provider->getChildren($share) as $child) {
+ $this->dispatcher->dispatchTyped(new BeforeShareDeletedEvent($child));
+
$deletedChildren = $this->deleteChildren($child);
$deletedShares = array_merge($deletedShares, $deletedChildren);
$provider->delete($child);
- $this->dispatcher->dispatchTyped(new Share\Events\ShareDeletedEvent($child));
+ $this->dispatcher->dispatchTyped(new ShareDeletedEvent($child));
$deletedShares[] = $child;
}
@@ -1229,24 +1234,16 @@ class Manager implements IManager {
throw new \InvalidArgumentException('Share does not have a full id');
}
- $event = new GenericEvent($share);
- $this->legacyDispatcher->dispatch('OCP\Share::preUnshare', $event);
+ $this->dispatcher->dispatchTyped(new BeforeShareDeletedEvent($share));
// Get all children and delete them as well
- $deletedShares = $this->deleteChildren($share);
+ $this->deleteChildren($share);
// Do the actual delete
$provider = $this->factory->getProviderForType($share->getShareType());
$provider->delete($share);
- $this->dispatcher->dispatchTyped(new Share\Events\ShareDeletedEvent($share));
-
- // All the deleted shares caused by this delete
- $deletedShares[] = $share;
-
- // Emit post hook
- $event->setArgument('deletedShares', $deletedShares);
- $this->legacyDispatcher->dispatch('OCP\Share::postUnshare', $event);
+ $this->dispatcher->dispatchTyped(new ShareDeletedEvent($share));
}
@@ -1264,8 +1261,8 @@ class Manager implements IManager {
$provider = $this->factory->getProvider($providerId);
$provider->deleteFromSelf($share, $recipientId);
- $event = new GenericEvent($share);
- $this->legacyDispatcher->dispatch('OCP\Share::postUnshareFromSelf', $event);
+ $event = new ShareDeletedFromSelfEvent($share);
+ $this->dispatcher->dispatchTyped($event);
}
public function restoreShare(IShare $share, string $recipientId): IShare {