diff --git a/src/EventListener/ProfileChangeListener.php b/src/EventListener/ProfileChangeListener.php index 0c534c7..e38fdd4 100644 --- a/src/EventListener/ProfileChangeListener.php +++ b/src/EventListener/ProfileChangeListener.php @@ -20,6 +20,13 @@ final class ProfileChangeListener implements EventSubscriberInterface { + private readonly EventDispatcherInterface $eventDispatcher; + + public function __construct(EventDispatcherInterface $eventDispatcher) + { + $this->eventDispatcher = $eventDispatcher; + } + /** * @return array */ @@ -30,9 +37,9 @@ public static function getSubscribedEvents(): array ]; } - public function profileChanged(FilterUserResponseEvent $event, string $eventName, EventDispatcherInterface $eventDispatcher): void + public function profileChanged(FilterUserResponseEvent $event): void { - $eventDispatcher->dispatch(new UserEvent($event->getUser(), $event->getRequest()), NucleosUserEvents::USER_LOCALE_CHANGED); - $eventDispatcher->dispatch(new UserEvent($event->getUser(), $event->getRequest()), NucleosUserEvents::USER_TIMEZONE_CHANGED); + $this->eventDispatcher->dispatch(new UserEvent($event->getUser(), $event->getRequest()), NucleosUserEvents::USER_LOCALE_CHANGED); + $this->eventDispatcher->dispatch(new UserEvent($event->getUser(), $event->getRequest()), NucleosUserEvents::USER_TIMEZONE_CHANGED); } } diff --git a/src/Resources/config/listeners.php b/src/Resources/config/listeners.php index c557f64..89a8817 100644 --- a/src/Resources/config/listeners.php +++ b/src/Resources/config/listeners.php @@ -14,6 +14,7 @@ use Nucleos\ProfileBundle\EventListener\AlreadyLoggedinListener; use Nucleos\ProfileBundle\EventListener\AuthenticationListener; use Nucleos\ProfileBundle\EventListener\FlashListener; +use Nucleos\ProfileBundle\EventListener\ProfileChangeListener; use Symfony\Component\DependencyInjection\Parameter; use Symfony\Component\DependencyInjection\Reference; @@ -34,6 +35,12 @@ new Reference('router'), ]) + ->set(ProfileChangeListener::class) + ->tag('kernel.event_subscriber') + ->args([ + new Reference('event_dispatcher'), + ]) + ->set(FlashListener::class) ->tag('kernel.event_subscriber') ->args([