diff options
author | Joas Schilling <coding@schilljs.com> | 2023-07-28 14:10:27 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2023-07-28 14:11:22 +0200 |
commit | 3962cd0aa8ab7530deffa3b41cab2e11a01fd14a (patch) | |
tree | f8ec289aacdf05398e2407b8e7e54b547ee1986e /lib | |
parent | b9e2f494a1307dac05b49fe74a224dc93f4c70e7 (diff) | |
download | nextcloud-server-3962cd0aa8ab7530deffa3b41cab2e11a01fd14a.tar.gz nextcloud-server-3962cd0aa8ab7530deffa3b41cab2e11a01fd14a.zip |
fix!: Move getEventDispatcher usage to IEventDispatcher
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/Files/Node/Node.php | 6 | ||||
-rw-r--r-- | lib/private/User/Session.php | 6 | ||||
-rw-r--r-- | lib/private/legacy/OC_App.php | 2 | ||||
-rw-r--r-- | lib/public/User/Events/UserFirstTimeLoggedInEvent.php | 50 |
6 files changed, 61 insertions, 5 deletions
diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php index 19d5eb1fe7d..bbc53543bef 100644 --- a/lib/composer/composer/autoload_classmap.php +++ b/lib/composer/composer/autoload_classmap.php @@ -688,6 +688,7 @@ return array( 'OCP\\User\\Events\\UserChangedEvent' => $baseDir . '/lib/public/User/Events/UserChangedEvent.php', 'OCP\\User\\Events\\UserCreatedEvent' => $baseDir . '/lib/public/User/Events/UserCreatedEvent.php', 'OCP\\User\\Events\\UserDeletedEvent' => $baseDir . '/lib/public/User/Events/UserDeletedEvent.php', + 'OCP\\User\\Events\\UserFirstTimeLoggedInEvent' => $baseDir . '/lib/public/User/Events/UserFirstTimeLoggedInEvent.php', 'OCP\\User\\Events\\UserLiveStatusEvent' => $baseDir . '/lib/public/User/Events/UserLiveStatusEvent.php', 'OCP\\User\\Events\\UserLoggedInEvent' => $baseDir . '/lib/public/User/Events/UserLoggedInEvent.php', 'OCP\\User\\Events\\UserLoggedInWithCookieEvent' => $baseDir . '/lib/public/User/Events/UserLoggedInWithCookieEvent.php', diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php index a67598a4464..36cc599b209 100644 --- a/lib/composer/composer/autoload_static.php +++ b/lib/composer/composer/autoload_static.php @@ -721,6 +721,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2 'OCP\\User\\Events\\UserChangedEvent' => __DIR__ . '/../../..' . '/lib/public/User/Events/UserChangedEvent.php', 'OCP\\User\\Events\\UserCreatedEvent' => __DIR__ . '/../../..' . '/lib/public/User/Events/UserCreatedEvent.php', 'OCP\\User\\Events\\UserDeletedEvent' => __DIR__ . '/../../..' . '/lib/public/User/Events/UserDeletedEvent.php', + 'OCP\\User\\Events\\UserFirstTimeLoggedInEvent' => __DIR__ . '/../../..' . '/lib/public/User/Events/UserFirstTimeLoggedInEvent.php', 'OCP\\User\\Events\\UserLiveStatusEvent' => __DIR__ . '/../../..' . '/lib/public/User/Events/UserLiveStatusEvent.php', 'OCP\\User\\Events\\UserLoggedInEvent' => __DIR__ . '/../../..' . '/lib/public/User/Events/UserLoggedInEvent.php', 'OCP\\User\\Events\\UserLoggedInWithCookieEvent' => __DIR__ . '/../../..' . '/lib/public/User/Events/UserLoggedInWithCookieEvent.php', diff --git a/lib/private/Files/Node/Node.php b/lib/private/Files/Node/Node.php index 4ba2c472c67..61ae762638f 100644 --- a/lib/private/Files/Node/Node.php +++ b/lib/private/Files/Node/Node.php @@ -32,6 +32,8 @@ namespace OC\Files\Node; use OC\Files\Filesystem; use OC\Files\Mount\MoveableMount; use OC\Files\Utils\PathHelper; +use OCP\EventDispatcher\GenericEvent; +use OCP\EventDispatcher\IEventDispatcher; use OCP\Files\FileInfo; use OCP\Files\InvalidPathException; use OCP\Files\IRootFolder; @@ -40,7 +42,6 @@ use OCP\Files\NotFoundException; use OCP\Files\NotPermittedException; use OCP\Lock\LockedException; use OCP\PreConditionNotMetException; -use Symfony\Component\EventDispatcher\GenericEvent; // FIXME: this class really should be abstract class Node implements INode { @@ -127,7 +128,8 @@ class Node implements INode { */ protected function sendHooks($hooks, array $args = null) { $args = !empty($args) ? $args : [$this]; - $dispatcher = \OC::$server->getEventDispatcher(); + /** @var IEventDispatcher $dispatcher */ + $dispatcher = \OC::$server->get(IEventDispatcher::class); foreach ($hooks as $hook) { if (method_exists($this->root, 'emit')) { $this->root->emit('\OC\Files', $hook, $args); diff --git a/lib/private/User/Session.php b/lib/private/User/Session.php index 840a3c04373..e7075bce47a 100644 --- a/lib/private/User/Session.php +++ b/lib/private/User/Session.php @@ -51,6 +51,7 @@ use OC_User; use OC_Util; use OCA\DAV\Connector\Sabre\Auth; use OCP\AppFramework\Utility\ITimeFactory; +use OCP\EventDispatcher\GenericEvent; use OCP\EventDispatcher\IEventDispatcher; use OCP\Files\NotPermittedException; use OCP\IConfig; @@ -63,9 +64,9 @@ use OCP\Security\Bruteforce\IThrottler; use OCP\Security\ISecureRandom; use OCP\Session\Exceptions\SessionNotAvailableException; use OCP\User\Events\PostLoginEvent; +use OCP\User\Events\UserFirstTimeLoggedInEvent; use OCP\Util; use Psr\Log\LoggerInterface; -use Symfony\Component\EventDispatcher\GenericEvent; /** * Class Session @@ -561,7 +562,8 @@ class Session implements IUserSession, Emitter { } // trigger any other initialization - \OC::$server->getEventDispatcher()->dispatch(IUser::class . '::firstLogin', new GenericEvent($this->getUser())); + \OC::$server->get(IEventDispatcher::class)->dispatch(IUser::class . '::firstLogin', new GenericEvent($this->getUser())); + \OC::$server->get(IEventDispatcher::class)->dispatchTyped(new UserFirstTimeLoggedInEvent($this->getUser())); } } diff --git a/lib/private/legacy/OC_App.php b/lib/private/legacy/OC_App.php index 9337492e775..ac449a62a4f 100644 --- a/lib/private/legacy/OC_App.php +++ b/lib/private/legacy/OC_App.php @@ -802,7 +802,7 @@ class OC_App { \OC::$server->getConfig()->setAppValue($appId, 'installed_version', $version); \OC::$server->get(IEventDispatcher::class)->dispatchTyped(new AppUpdateEvent($appId)); - \OC::$server->getEventDispatcher()->dispatch(ManagerEvent::EVENT_APP_UPDATE, new ManagerEvent( + \OC::$server->get(IEventDispatcher::class)->dispatch(ManagerEvent::EVENT_APP_UPDATE, new ManagerEvent( ManagerEvent::EVENT_APP_UPDATE, $appId )); diff --git a/lib/public/User/Events/UserFirstTimeLoggedInEvent.php b/lib/public/User/Events/UserFirstTimeLoggedInEvent.php new file mode 100644 index 00000000000..06491f79109 --- /dev/null +++ b/lib/public/User/Events/UserFirstTimeLoggedInEvent.php @@ -0,0 +1,50 @@ +<?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\User\Events; + +use OCP\EventDispatcher\Event; +use OCP\IUser; + +/** + * @since 28.0.0 + */ +class UserFirstTimeLoggedInEvent extends Event { + /** + * @since 28.0.0 + */ + public function __construct( + private IUser $user, + ) { + parent::__construct(); + } + + /** + * @since 28.0.0 + */ + public function getUser(): IUser { + return $this->user; + } +} |