fix(loopup_server_connector): Migrate to IEventDispatcher

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2023-07-07 11:28:02 +02:00
parent a6bf93501d
commit 4877d0b62e
No known key found for this signature in database
GPG key ID: 74434EFE0D2E2205

View file

@ -34,9 +34,9 @@ use OCP\AppFramework\App;
use OCP\AppFramework\Bootstrap\IBootContext;
use OCP\AppFramework\Bootstrap\IBootstrap;
use OCP\AppFramework\Bootstrap\IRegistrationContext;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IUser;
use Psr\Container\ContainerInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\GenericEvent;
class Application extends App implements IBootstrap {
@ -56,15 +56,17 @@ class Application extends App implements IBootstrap {
/**
* @todo move the OCP events and then move the registration to `register`
*/
private function registerEventListeners(EventDispatcherInterface $dispatcher,
private function registerEventListeners(IEventDispatcher $dispatcher,
ContainerInterface $appContainer): void {
$dispatcher->addListener('OC\AccountManager::userUpdated', function (GenericEvent $event) use ($appContainer) {
/** @var IUser $user */
$user = $event->getSubject();
$dispatcher->addListener('OC\AccountManager::userUpdated', function ($event) use ($appContainer) {
if ($event instanceof GenericEvent) {
/** @var IUser $user */
$user = $event->getSubject();
/** @var UpdateLookupServer $updateLookupServer */
$updateLookupServer = $appContainer->get(UpdateLookupServer::class);
$updateLookupServer->userUpdated($user);
/** @var UpdateLookupServer $updateLookupServer */
$updateLookupServer = $appContainer->get(UpdateLookupServer::class);
$updateLookupServer->userUpdated($user);
}
});
}
}