<?php
declare(strict_types=1);
namespace App\Bundles\UserBundle\EventListener;
use App\Bundles\UserBundle\Event\UserCreatedEvent;
use App\Bundles\UserBundle\Service\UserEmail\UserEmailSender;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class UserCreatedListener implements EventSubscriberInterface
{
public function __construct(
private readonly UserEmailSender $emailSender,
) {
}
public static function getSubscribedEvents(): array
{
return [
UserCreatedEvent::NAME => 'onUserCreated',
];
}
public function onUserCreated(UserCreatedEvent $event): void
{
$this->emailSender->sendRegistrationEmail($event->getUser());
}
}