src/EventsSubscriber/Payment/PaymentEventsSubscriber.php line 27

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\EventsSubscriber\Payment;
  4. use App\Event\User\CreatedEvent;
  5. use App\Services\Payment\PaymentServiceInterface;
  6. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  7. class PaymentEventsSubscriber implements EventSubscriberInterface
  8. {
  9.     public function __construct(
  10.         private readonly PaymentServiceInterface $paymentService,
  11.     ) {
  12.     }
  13.     public static function getSubscribedEvents(): array
  14.     {
  15.         return [
  16.             CreatedEvent::class => [
  17.                 ['initializePayment'],
  18.             ],
  19.         ];
  20.     }
  21.     public function initializePayment(CreatedEvent $event): void
  22.     {
  23.         $this->paymentService->initializeUser($event->getUser());
  24.     }
  25. }