<?php
declare(strict_types=1);
namespace MadFrontendContactForm\Core\Subscriber;
use MadFrontendContactForm\Core\Event\SendFrontendContactFormToCustomerEvent;
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 => ['onAddSendcontactFormtoCustomerEvent', 1000],
];
}
public function onAddSendcontactFormtoCustomerEvent(BusinessEventCollectorEvent $event): void
{
$collection = $event->getCollection();
$definition = $this->businessEventCollector->define(SendFrontendContactFormToCustomerEvent::class);
if (!$definition) {
return;
}
$collection->set($definition->getName(), $definition);
}
}