Lines
100.00%
8 / 8
Methods
100.00%
2 / 2
Classes
100.00%
1 / 1
| Name | Lines | Methods | CRAP | ||||
|---|---|---|---|---|---|---|---|
| __construct | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| __invoke | 100.00% | 7 / 7 | 100.00% | 1 / 1 | 5 | ||
| 18 | final readonly class ChooseVisibilityListener | |
| 19 | { | |
| 20 | public function __construct(private UrlGeneratorInterface $urlGenerator) | |
| 21 | { | |
| 22 | } | |
| 23 | ||
| 24 | public function __invoke(LoginSuccessEvent $event): void | |
| 25 | { | |
| 26 | $user = $event->getUser(); | |
| 27 | if ('main' !== $event->getFirewallName() | |
| 28 | || !$event->getResponse() instanceof RedirectResponse | |
| 29 | || !$user instanceof User | |
| 30 | || $user->getVisibilityChosenAt() instanceof \DateTimeImmutable | |
| 31 | ) { | |
| 32 | return; | |
| 33 | } | |
| 34 | ||
| 35 | $event->setResponse(new RedirectResponse($this->urlGenerator->generate('app_profile'))); | |
| 36 | } | |
| 37 | } |