diff options
author | Joas Schilling <coding@schilljs.com> | 2023-07-27 19:57:10 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2023-07-28 14:11:19 +0200 |
commit | 68fc9b48c24bf810488c5910da2feadd10587e51 (patch) | |
tree | cf183d9afa8f2fa5a9342341f4cf21d51bc6ad50 /lib | |
parent | 9bf812ac6c29f7722ba6db876dbabbc1b065dce1 (diff) | |
download | nextcloud-server-68fc9b48c24bf810488c5910da2feadd10587e51.tar.gz nextcloud-server-68fc9b48c24bf810488c5910da2feadd10587e51.zip |
feat!: Migrate AccountManager event to typed event
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/composer/composer/autoload_classmap.php | 1 | ||||
-rw-r--r-- | lib/composer/composer/autoload_static.php | 1 | ||||
-rw-r--r-- | lib/private/Accounts/AccountManager.php | 14 | ||||
-rw-r--r-- | lib/public/Accounts/UserUpdatedEvent.php | 58 |
4 files changed, 67 insertions, 7 deletions
diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php index 38cad1e9eb4..1093b8a2586 100644 --- a/lib/composer/composer/autoload_classmap.php +++ b/lib/composer/composer/autoload_classmap.php @@ -12,6 +12,7 @@ return array( 'OCP\\Accounts\\IAccountProperty' => $baseDir . '/lib/public/Accounts/IAccountProperty.php', 'OCP\\Accounts\\IAccountPropertyCollection' => $baseDir . '/lib/public/Accounts/IAccountPropertyCollection.php', 'OCP\\Accounts\\PropertyDoesNotExistException' => $baseDir . '/lib/public/Accounts/PropertyDoesNotExistException.php', + 'OCP\\Accounts\\UserUpdatedEvent' => $baseDir . '/lib/public/Accounts/UserUpdatedEvent.php', 'OCP\\Activity\\ActivitySettings' => $baseDir . '/lib/public/Activity/ActivitySettings.php', 'OCP\\Activity\\IConsumer' => $baseDir . '/lib/public/Activity/IConsumer.php', 'OCP\\Activity\\IEvent' => $baseDir . '/lib/public/Activity/IEvent.php', diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php index 9083632b384..4a74dda6fab 100644 --- a/lib/composer/composer/autoload_static.php +++ b/lib/composer/composer/autoload_static.php @@ -45,6 +45,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2 'OCP\\Accounts\\IAccountProperty' => __DIR__ . '/../../..' . '/lib/public/Accounts/IAccountProperty.php', 'OCP\\Accounts\\IAccountPropertyCollection' => __DIR__ . '/../../..' . '/lib/public/Accounts/IAccountPropertyCollection.php', 'OCP\\Accounts\\PropertyDoesNotExistException' => __DIR__ . '/../../..' . '/lib/public/Accounts/PropertyDoesNotExistException.php', + 'OCP\\Accounts\\UserUpdatedEvent' => __DIR__ . '/../../..' . '/lib/public/Accounts/UserUpdatedEvent.php', 'OCP\\Activity\\ActivitySettings' => __DIR__ . '/../../..' . '/lib/public/Activity/ActivitySettings.php', 'OCP\\Activity\\IConsumer' => __DIR__ . '/../../..' . '/lib/public/Activity/IConsumer.php', 'OCP\\Activity\\IEvent' => __DIR__ . '/../../..' . '/lib/public/Activity/IEvent.php', diff --git a/lib/private/Accounts/AccountManager.php b/lib/private/Accounts/AccountManager.php index 43d18a0d941..95199d8380c 100644 --- a/lib/private/Accounts/AccountManager.php +++ b/lib/private/Accounts/AccountManager.php @@ -41,6 +41,7 @@ use libphonenumber\NumberParseException; use libphonenumber\PhoneNumberFormat; use libphonenumber\PhoneNumberUtil; use OC\Profile\TProfileHelper; +use OCP\Accounts\UserUpdatedEvent; use OCP\Cache\CappedMemoryCache; use OCA\Settings\BackgroundJobs\VerifyUserData; use OCP\Accounts\IAccount; @@ -51,6 +52,7 @@ use OCP\Accounts\PropertyDoesNotExistException; use OCP\BackgroundJob\IJobList; use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\Defaults; +use OCP\EventDispatcher\IEventDispatcher; use OCP\IConfig; use OCP\IDBConnection; use OCP\IL10N; @@ -62,8 +64,6 @@ use OCP\Security\ICrypto; use OCP\Security\VerificationToken\IVerificationToken; use OCP\Util; use Psr\Log\LoggerInterface; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; -use Symfony\Component\EventDispatcher\GenericEvent; use function array_flip; use function iterator_to_array; use function json_decode; @@ -109,7 +109,7 @@ class AccountManager implements IAccountManager { public function __construct( private IDBConnection $connection, private IConfig $config, - private EventDispatcherInterface $eventDispatcher, + private IEventDispatcher $dispatcher, private IJobList $jobList, private LoggerInterface $logger, private IVerificationToken $verificationToken, @@ -255,10 +255,10 @@ class AccountManager implements IAccountManager { } if ($updated) { - $this->eventDispatcher->dispatch( - 'OC\AccountManager::userUpdated', - new GenericEvent($user, $data) - ); + $this->dispatcher->dispatchTyped(new UserUpdatedEvent( + $user, + $data, + )); } return $data; diff --git a/lib/public/Accounts/UserUpdatedEvent.php b/lib/public/Accounts/UserUpdatedEvent.php new file mode 100644 index 00000000000..e6c73f1d1c1 --- /dev/null +++ b/lib/public/Accounts/UserUpdatedEvent.php @@ -0,0 +1,58 @@ +<?php + +declare(strict_types=1); + +/** + * @copyright Copyright (c) 2023 Joas Schilling <coding@schilljs.com> + * + * @author Joas Schilling <coding@schilljs.com> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ +namespace OCP\Accounts; + +use OCP\EventDispatcher\Event; +use OCP\IUser; + +/** + * @since 28.0.0 + */ +class UserUpdatedEvent extends Event { + /** + * @since 28.0.0 + */ + public function __construct( + protected IUser $user, + protected array $data, + ) { + parent::__construct(); + } + + /** + * @since 28.0.0 + */ + public function getUser(): IUser { + return $this->user; + } + + /** + * @since 28.0.0 + */ + public function getData(): array { + return $this->data; + } +} |