<?php
declare(strict_types=1);
namespace App\Services\Payment\EventSubscriber;
use App\Services\Creator\Event\CreatorCreatedEvent;
use App\Services\Payment\PaymentServiceInterface;
use App\Services\Sponsor\Event\SponsorCreatedEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class UserEventSubscriber implements EventSubscriberInterface
{
public static function getSubscribedEvents(): array
{
return [
CreatorCreatedEvent::class => 'onCreatorCreated',
SponsorCreatedEvent::class => 'onSponsorCreated',
];
}
public function __construct(
private PaymentServiceInterface $paymentService,
) {
}
public function onCreatorCreated(CreatorCreatedEvent $event): void
{
$this->paymentService->initializeUser($event->getCreator());
}
public function onSponsorCreated(SponsorCreatedEvent $event): void
{
$this->paymentService->initializeUser($event->getSponsor());
}
}