src/EventSubscriber/InvoicePaymentSubscriber.php line 32

Open in your IDE?
  1. <?php
  2. /**
  3.  * This file is part of the CosaVostra, TrackPay package.
  4.  *
  5.  * (c) Mohamed Radhi GUENNICHI <rg@mate.tn> <+216 50 711 816>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. declare(strict_types=1);
  11. namespace App\EventSubscriber;
  12. use App\Entity\PaymentRequestEvent;
  13. use App\Event\InvoicePaymentEvent;
  14. use App\Repository\PaymentRequestEventRepository;
  15. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  16. class InvoicePaymentSubscriber implements EventSubscriberInterface
  17. {
  18.     /**
  19.      * @var PaymentRequestEventRepository
  20.      */
  21.     protected $paymentRequestEventRepository;
  22.     public function __construct(PaymentRequestEventRepository $paymentRequestEventRepository)
  23.     {
  24.         $this->paymentRequestEventRepository $paymentRequestEventRepository;
  25.     }
  26.     public function onPayment(InvoicePaymentEvent $event): void
  27.     {
  28.         $this->paymentRequestEventRepository->save(
  29.             (new PaymentRequestEvent())
  30.                 ->setProcedure($event->getProcedure())
  31.                 ->setMethod($event->getPaymentMethod())
  32.         );
  33.     }
  34.     /**
  35.      * @inheritDoc
  36.      */
  37.     public static function getSubscribedEvents()
  38.     {
  39.         return [
  40.             InvoicePaymentEvent::class => 'onPayment'
  41.         ];
  42.     }
  43. }