diff options
author | Morris Jobke <hey@morrisjobke.de> | 2020-11-23 23:59:50 +0100 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2020-11-23 23:59:52 +0100 |
commit | 9bf76d2bad08b2e8c8e6bab9f3e514515fb89058 (patch) | |
tree | 7b552ca61e16414eb375c3f90765dabd9f9e9efd /lib/private/User | |
parent | d9e0efbf72e1f57abfbfffd3e547ba171e867d78 (diff) | |
download | nextcloud-server-9bf76d2bad08b2e8c8e6bab9f3e514515fb89058.tar.gz nextcloud-server-9bf76d2bad08b2e8c8e6bab9f3e514515fb89058.zip |
Streamline user creation and deletion events
CreateUserEvent was the only one that didn't matched the naming scheme of BeforePASTTENSEEvent and PASTTENSEEvent. The event wasn't used at all so this just removes it again as there is BeforeUserCreatedEvent that is also available since 18.
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
Diffstat (limited to 'lib/private/User')
-rw-r--r-- | lib/private/User/Manager.php | 8 | ||||
-rw-r--r-- | lib/private/User/User.php | 8 |
2 files changed, 12 insertions, 4 deletions
diff --git a/lib/private/User/Manager.php b/lib/private/User/Manager.php index debe2f14f2e..1201a456ce2 100644 --- a/lib/private/User/Manager.php +++ b/lib/private/User/Manager.php @@ -43,7 +43,7 @@ use OCP\IUser; use OCP\IUserBackend; use OCP\IUserManager; use OCP\User\Backend\IGetRealUIDBackend; -use OCP\User\Events\CreateUserEvent; +use OCP\User\Events\BeforeUserCreatedEvent; use OCP\User\Events\UserCreatedEvent; use OCP\UserInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; @@ -365,16 +365,16 @@ class Manager extends PublicEmitter implements IUserManager { throw new \InvalidArgumentException($l->t('The username is already being used')); } - /** @depreacted 21.0.0 use CreateUserEvent event with the IEventDispatcher instead */ + /** @deprecated 21.0.0 use BeforeUserCreatedEvent event with the IEventDispatcher instead */ $this->emit('\OC\User', 'preCreateUser', [$uid, $password]); - $this->eventDispatcher->dispatchTyped(new CreateUserEvent($uid, $password)); + $this->eventDispatcher->dispatchTyped(new BeforeUserCreatedEvent($uid, $password)); $state = $backend->createUser($uid, $password); if ($state === false) { throw new \InvalidArgumentException($l->t('Could not create user')); } $user = $this->getUserObject($uid, $backend); if ($user instanceof IUser) { - /** @depreacted 21.0.0 use UserCreatedEvent event with the IEventDispatcher instead */ + /** @deprecated 21.0.0 use UserCreatedEvent event with the IEventDispatcher instead */ $this->emit('\OC\User', 'postCreateUser', [$user, $password]); $this->eventDispatcher->dispatchTyped(new UserCreatedEvent($user, $password)); } diff --git a/lib/private/User/User.php b/lib/private/User/User.php index 3ca05afb313..c1dc8b91af8 100644 --- a/lib/private/User/User.php +++ b/lib/private/User/User.php @@ -50,6 +50,8 @@ use OCP\IImage; use OCP\IURLGenerator; use OCP\IUser; use OCP\IUserBackend; +use OCP\User\Events\BeforeUserDeletedEvent; +use OCP\User\Events\UserDeletedEvent; use OCP\User\GetQuotaEvent; use OCP\UserInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; @@ -212,10 +214,13 @@ class User implements IUser { * @return bool */ public function delete() { + /** @deprecated 21.0.0 use BeforeUserDeletedEvent event with the IEventDispatcher instead */ $this->legacyDispatcher->dispatch(IUser::class . '::preDelete', new GenericEvent($this)); if ($this->emitter) { + /** @deprecated 21.0.0 use BeforeUserDeletedEvent event with the IEventDispatcher instead */ $this->emitter->emit('\OC\User', 'preDelete', [$this]); } + $this->dispatcher->dispatchTyped(new BeforeUserDeletedEvent($this)); // get the home now because it won't return it after user deletion $homePath = $this->getHome(); $result = $this->backend->deleteUser($this->uid); @@ -261,10 +266,13 @@ class User implements IUser { $accountManager = \OC::$server->query(AccountManager::class); $accountManager->deleteUser($this); + /** @deprecated 21.0.0 use UserDeletedEvent event with the IEventDispatcher instead */ $this->legacyDispatcher->dispatch(IUser::class . '::postDelete', new GenericEvent($this)); if ($this->emitter) { + /** @deprecated 21.0.0 use UserDeletedEvent event with the IEventDispatcher instead */ $this->emitter->emit('\OC\User', 'postDelete', [$this]); } + $this->dispatcher->dispatchTyped(new UserDeletedEvent($this)); } return !($result === false); } |