<?php
namespace App\Domain\Module\Subscriber;
use App\Domain\Auth\Event\UserCreatedEvent;
use App\Domain\Auth\Service\UserRegisterService;
use App\Domain\Module\Service\ModuleService;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class UserCreatedEventSubscriber implements EventSubscriberInterface
{
private ModuleService $service;
public function __construct(ModuleService $service)
{
$this->service = $service;
}
public static function getSubscribedEvents(): array
{
return [
UserCreatedEvent::class => 'onCreated',
];
}
public function onCreated(UserCreatedEvent $event): void
{
$this->service->addModule($event->getUser());
}
}