src/EventSubscriber/QuotationSubmitEventSubscriber.php line 43

Open in your IDE?
  1. <?php
  2. namespace App\EventSubscriber;
  3. use App\Event\QuotationSubmitEvent;
  4. use App\Producer\GlobalProducer;
  5. use App\Service\Api\MailchimpService;
  6. use App\Service\RabbitMQ\RabbitMQDispatcher;
  7. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  8. class QuotationSubmitEventSubscriber implements EventSubscriberInterface
  9. {
  10.     private $rabbitMQDispatcher;
  11.     private $mailchimp;
  12.     public function __construct(
  13.         RabbitMQDispatcher $rabbitMQDispatcher,
  14.         MailchimpService $mailchimpService
  15.     )
  16.     {
  17.         $this->mailchimp $mailchimpService;
  18.         $this->rabbitMQDispatcher $rabbitMQDispatcher;
  19.     }
  20.     public static function getSubscribedEvents()
  21.     {
  22.         return [
  23.             QuotationSubmitEvent::STAGE_1 => ['addMailChimpListMember'],
  24.             QuotationSubmitEvent::STAGE_2 => ['updateMailChimpListMemberTag']
  25.         ];
  26.     }
  27.     public function addMailChimpListMember(QuotationSubmitEvent $event)
  28.     {
  29.         $this->rabbitMQDispatcher->dispatch([
  30.             'data' => ['email' => $event->getQuotation()->getEmail()],
  31.             'action_name' => 'addListMember',
  32.             'consumer_name' => 'mail_chimp_consumer'
  33.         ]);
  34.     }
  35.     public function updateMailChimpListMemberTag(QuotationSubmitEvent $event)
  36.     {
  37.         $this->rabbitMQDispatcher->dispatch([
  38.             'data' => ['email' => $event->getQuotation()->getEmail()],
  39.             'action_name' => 'updateListMemberTag',
  40.             'consumer_name' => 'mail_chimp_consumer'
  41.         ]);
  42.     }
  43. }