src/Services/Payment/EventSubscriber/UserEventSubscriber.php line 27

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Services\Payment\EventSubscriber;
  4. use App\Services\Creator\Event\CreatorCreatedEvent;
  5. use App\Services\Payment\PaymentServiceInterface;
  6. use App\Services\Sponsor\Event\SponsorCreatedEvent;
  7. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  8. class UserEventSubscriber implements EventSubscriberInterface
  9. {
  10.     public static function getSubscribedEvents(): array
  11.     {
  12.         return [
  13.             CreatorCreatedEvent::class => 'onCreatorCreated',
  14.             SponsorCreatedEvent::class => 'onSponsorCreated',
  15.         ];
  16.     }
  17.     public function __construct(
  18.         private PaymentServiceInterface $paymentService,
  19.     ) {
  20.     }
  21.     public function onCreatorCreated(CreatorCreatedEvent $event): void
  22.     {
  23.         $this->paymentService->initializeUser($event->getCreator());
  24.     }
  25.     public function onSponsorCreated(SponsorCreatedEvent $event): void
  26.     {
  27.         $this->paymentService->initializeUser($event->getSponsor());
  28.     }
  29. }