<?php
namespace ProxaEmployee\Subscribers;
use ProxaEmployee\Services\ConfigService;
use Shopware\Core\Content\Flow\Events\FlowSendMailActionEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class FlowSubscriber implements EventSubscriberInterface
{
/**
* @var ConfigService
*/
private ConfigService $configService;
/**
* @param ConfigService $configService
*/
public function __construct(
ConfigService $configService
)
{
$this->configService = $configService;
}
/**
* @return string[]
*/
public static function getSubscribedEvents(): array
{
return [
FlowSendMailActionEvent::class => 'onFlowSendMailActionEvent'
];
}
/**
* @param FlowSendMailActionEvent $event
* @return void
*/
public function onFlowSendMailActionEvent(FlowSendMailActionEvent $event)
{
if ($event->getFlowEvent()->getName() === 'checkout.customer.register') {
$this->configService->setDefaultCustomerRegisterMailTemplateId($event->getMailTemplate()->getId());
}
}
}