<?php
namespace App\EventSubscriber;
use App\Event\WebShopEvent;
use App\Service\Constants\LogEvents;
use App\Service\RabbitMQ\RabbitMQDispatcher;
use App\Service\Subscription\SubscriptionService;
use App\Service\UserLog;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class WebShopSubscriber implements EventSubscriberInterface
{
protected RabbitMQDispatcher $rabbitMQDispatcher;
protected SubscriptionService $subscriptionService;
public function __construct(
RabbitMQDispatcher $rabbitMQDispatcher,
SubscriptionService $subscriptionService,
UserLog $userLog
)
{
$this->rabbitMQDispatcher = $rabbitMQDispatcher;
$this->subscriptionService = $subscriptionService;
$this->userLog = $userLog;
}
public static function getSubscribedEvents(): array
{
return [
WebShopEvent::WEB_SHOP_QUOTATION_NEW => [
// ['sendNewQuotationRegisteredEmail']
['sendOrderRegistrationFinishedEmail']
],
WebShopEvent::WEB_SHOP_PAYMENT_SUCCESS => [
['sendPaymentSuccessEmail']
],
WebShopEvent::WEB_SHOP_PAYMENT_FAIL => [
['sendPaymentFailEmail']
],
WebShopEvent::WEB_SHOP_QUOTATION_FINISHED => [
['sendOrderRegistrationFinishedEmail']
],
WebShopEvent::WEB_SHOP_QUOTATION_NO_DESIGN => [
['sendOrderRegistrationNoDesignEmail']
],
];
}
public function sendNewQuotationRegisteredEmail(WebShopEvent $event)
{
$this->rabbitMQDispatcher->dispatch([
'data' => [
'user_uuid' => $event->getUser()->getUuid(),
'order_uuid' => $event->getOrder()->getUuid(),
],
'action_name' => 'webShopNewQuotationRegisteredEmail',
'consumer_name' => 'notification_consumer'
]);
}
public function sendPaymentSuccessEmail(WebShopEvent $event)
{
$this->rabbitMQDispatcher->dispatch([
'data' => [
'user_email' => $event->getUser()->getEmail(),
'invoice_uuid' => $event->getInvoice()->getUuid(),
],
'action_name' => 'webShopPaymentSuccessEmail',
'consumer_name' => 'notification_consumer'
]);
}
public function sendPaymentFailEmail(WebShopEvent $event)
{
// $this->rabbitMQDispatcher->dispatch([
// 'data' => [
// 'user_email' => $event->getUser()->getEmail(),
// 'invoice_uuid' => $event->getInvoice()->getUuid(),
// ],
// 'action_name' => 'webShopPaymentFailEmail',
// 'consumer_name' => 'notification_consumer'
// ]);
}
public function sendOrderRegistrationFinishedEmail(WebShopEvent $event)
{
$this->rabbitMQDispatcher->dispatch([
'data' => [
'order_uuid' => $event->getOrder()->getUuid(),
],
'action_name' => 'webShopOrderRegistrationFinishedEmail',
'consumer_name' => 'notification_consumer'
]);
}
public function sendOrderRegistrationNoDesignEmail(WebShopEvent $event)
{
$this->rabbitMQDispatcher->dispatch([
'data' => [
'user_uuid' => $event->getUser()->getUuid(),
'order_uuid' => $event->getOrder()->getUuid(),
],
'action_name' => 'webShopOrderRegistrationNoDesignEmail',
'consumer_name' => 'notification_consumer'
]);
}
}