<?php
namespace App\EventSubscriber;
use App\Event\QuotationSubmitEvent;
use App\Producer\GlobalProducer;
use App\Service\Api\MailchimpService;
use App\Service\RabbitMQ\RabbitMQDispatcher;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class QuotationSubmitEventSubscriber implements EventSubscriberInterface
{
private $rabbitMQDispatcher;
private $mailchimp;
public function __construct(
RabbitMQDispatcher $rabbitMQDispatcher,
MailchimpService $mailchimpService
)
{
$this->mailchimp = $mailchimpService;
$this->rabbitMQDispatcher = $rabbitMQDispatcher;
}
public static function getSubscribedEvents()
{
return [
QuotationSubmitEvent::STAGE_1 => ['addMailChimpListMember'],
QuotationSubmitEvent::STAGE_2 => ['updateMailChimpListMemberTag']
];
}
public function addMailChimpListMember(QuotationSubmitEvent $event)
{
$this->rabbitMQDispatcher->dispatch([
'data' => ['email' => $event->getQuotation()->getEmail()],
'action_name' => 'addListMember',
'consumer_name' => 'mail_chimp_consumer'
]);
}
public function updateMailChimpListMemberTag(QuotationSubmitEvent $event)
{
$this->rabbitMQDispatcher->dispatch([
'data' => ['email' => $event->getQuotation()->getEmail()],
'action_name' => 'updateListMemberTag',
'consumer_name' => 'mail_chimp_consumer'
]);
}
}