<?php
declare(strict_types=1);
namespace MadCreateBuisnessMail\Core\Subscriber;
use MadCreateBuisnessMail\Core\Event\SendBuisnessMailEvent;
use Shopware\Core\Framework\Event\BusinessEventCollector;
use Shopware\Core\Framework\Event\BusinessEventCollectorEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class BusinessEventCollectorSubscriber implements EventSubscriberInterface
{
private BusinessEventCollector $businessEventCollector;
/**
* @param BusinessEventCollector $businessEventCollector
*/
public function __construct(BusinessEventCollector $businessEventCollector)
{
$this->businessEventCollector = $businessEventCollector;
}
public static function getSubscribedEvents(): array
{
return [
BusinessEventCollectorEvent::NAME => ['onAddSendBusinessCreateMailEvent', 1000],
];
}
public function onAddSendBusinessCreateMailEvent(BusinessEventCollectorEvent $event): void
{
$collection = $event->getCollection();
$definition = $this->businessEventCollector->define(SendBuisnessMailEvent::class);
if (!$definition) {
return;
}
$collection->set($definition->getName(), $definition);
}
}