Skip to content

Commit

Permalink
Register ProfileChangeListener
Browse files Browse the repository at this point in the history
  • Loading branch information
core23 committed Aug 14, 2024
1 parent 76b749d commit c47ed52
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/EventListener/ProfileChangeListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@

final class ProfileChangeListener implements EventSubscriberInterface
{
private readonly EventDispatcherInterface $eventDispatcher;

public function __construct(EventDispatcherInterface $eventDispatcher)
{
$this->eventDispatcher = $eventDispatcher;
}

/**
* @return array<string, string>
*/
Expand All @@ -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);
}
}
7 changes: 7 additions & 0 deletions src/Resources/config/listeners.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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([
Expand Down

0 comments on commit c47ed52

Please sign in to comment.