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