src/EventSubscriber/WebShopSubscriber.php line 88

Open in your IDE?
  1. <?php
  2. namespace App\EventSubscriber;
  3. use App\Event\WebShopEvent;
  4. use App\Service\Constants\LogEvents;
  5. use App\Service\RabbitMQ\RabbitMQDispatcher;
  6. use App\Service\Subscription\SubscriptionService;
  7. use App\Service\UserLog;
  8. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  9. class WebShopSubscriber implements EventSubscriberInterface
  10. {
  11.     protected RabbitMQDispatcher $rabbitMQDispatcher;
  12.     protected SubscriptionService $subscriptionService;
  13.     public function __construct(
  14.         RabbitMQDispatcher  $rabbitMQDispatcher,
  15.         SubscriptionService $subscriptionService,
  16.         UserLog             $userLog
  17.     )
  18.     {
  19.         $this->rabbitMQDispatcher $rabbitMQDispatcher;
  20.         $this->subscriptionService $subscriptionService;
  21.         $this->userLog $userLog;
  22.     }
  23.     public static function getSubscribedEvents(): array
  24.     {
  25.         return [
  26.             WebShopEvent::WEB_SHOP_QUOTATION_NEW => [
  27. //                ['sendNewQuotationRegisteredEmail']
  28.                 ['sendOrderRegistrationFinishedEmail']
  29.             ],
  30.             WebShopEvent::WEB_SHOP_PAYMENT_SUCCESS => [
  31.                 ['sendPaymentSuccessEmail']
  32.             ],
  33.             WebShopEvent::WEB_SHOP_PAYMENT_FAIL => [
  34.                 ['sendPaymentFailEmail']
  35.             ],
  36.             WebShopEvent::WEB_SHOP_QUOTATION_FINISHED => [
  37.                 ['sendOrderRegistrationFinishedEmail']
  38.             ],
  39.             WebShopEvent::WEB_SHOP_QUOTATION_NO_DESIGN => [
  40.                 ['sendOrderRegistrationNoDesignEmail']
  41.             ],
  42.         ];
  43.     }
  44.     public function sendNewQuotationRegisteredEmail(WebShopEvent $event)
  45.     {
  46.         $this->rabbitMQDispatcher->dispatch([
  47.             'data' => [
  48.                 'user_uuid' => $event->getUser()->getUuid(),
  49.                 'order_uuid' => $event->getOrder()->getUuid(),
  50.             ],
  51.             'action_name' => 'webShopNewQuotationRegisteredEmail',
  52.             'consumer_name' => 'notification_consumer'
  53.         ]);
  54.     }
  55.     public function sendPaymentSuccessEmail(WebShopEvent $event)
  56.     {
  57.         $this->rabbitMQDispatcher->dispatch([
  58.             'data' => [
  59.                 'user_email' => $event->getUser()->getEmail(),
  60.                 'invoice_uuid' => $event->getInvoice()->getUuid(),
  61.             ],
  62.             'action_name' => 'webShopPaymentSuccessEmail',
  63.             'consumer_name' => 'notification_consumer'
  64.         ]);
  65.     }
  66.     public function sendPaymentFailEmail(WebShopEvent $event)
  67.     {
  68. //        $this->rabbitMQDispatcher->dispatch([
  69. //            'data' => [
  70. //                'user_email' => $event->getUser()->getEmail(),
  71. //                'invoice_uuid' => $event->getInvoice()->getUuid(),
  72. //            ],
  73. //            'action_name' => 'webShopPaymentFailEmail',
  74. //            'consumer_name' => 'notification_consumer'
  75. //        ]);
  76.     }
  77.     public function sendOrderRegistrationFinishedEmail(WebShopEvent $event)
  78.     {
  79.         $this->rabbitMQDispatcher->dispatch([
  80.             'data' => [
  81.                 'order_uuid' => $event->getOrder()->getUuid(),
  82.             ],
  83.             'action_name' => 'webShopOrderRegistrationFinishedEmail',
  84.             'consumer_name' => 'notification_consumer'
  85.         ]);
  86.     }
  87.     public function sendOrderRegistrationNoDesignEmail(WebShopEvent $event)
  88.     {
  89.         $this->rabbitMQDispatcher->dispatch([
  90.             'data' => [
  91.                 'user_uuid' => $event->getUser()->getUuid(),
  92.                 'order_uuid' => $event->getOrder()->getUuid(),
  93.             ],
  94.             'action_name' => 'webShopOrderRegistrationNoDesignEmail',
  95.             'consumer_name' => 'notification_consumer'
  96.         ]);
  97.     }
  98. }