<?php
declare(strict_types=1);
namespace App\EventsSubscriber\Payment;
use App\Event\User\CreatedEvent;
use App\Services\Payment\PaymentServiceInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class PaymentEventsSubscriber implements EventSubscriberInterface
{
public function __construct(
private readonly PaymentServiceInterface $paymentService,
) {
}
public static function getSubscribedEvents(): array
{
return [
CreatedEvent::class => [
['initializePayment'],
],
];
}
public function initializePayment(CreatedEvent $event): void
{
$this->paymentService->initializeUser($event->getUser());
}
}