Skip to content

Commit

Permalink
Register ProfileChangeListener
Browse files Browse the repository at this point in the history
  • Loading branch information
core23 committed Jul 7, 2024
1 parent eaa64a1 commit f314502
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)

Check warning on line 25 in src/EventListener/ProfileChangeListener.php

View check run for this annotation

Codecov / codecov/patch

src/EventListener/ProfileChangeListener.php#L25

Added line #L25 was not covered by tests
{
$this->eventDispatcher = $eventDispatcher;

Check warning on line 27 in src/EventListener/ProfileChangeListener.php

View check run for this annotation

Codecov / codecov/patch

src/EventListener/ProfileChangeListener.php#L27

Added line #L27 was not covered by tests
}

/**
* @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

Check warning on line 40 in src/EventListener/ProfileChangeListener.php

View check run for this annotation

Codecov / codecov/patch

src/EventListener/ProfileChangeListener.php#L40

Added line #L40 was not covered by tests
{
$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);

Check warning on line 43 in src/EventListener/ProfileChangeListener.php

View check run for this annotation

Codecov / codecov/patch

src/EventListener/ProfileChangeListener.php#L42-L43

Added lines #L42 - L43 were not covered by tests
}
}
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 f314502

Please sign in to comment.