custom/plugins/AcrisCmsCS/src/Storefront/Subscriber/BusinessEventCollectorSubscriber.php line 25

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Acris\Cms\Storefront\Subscriber;
  3. use Acris\Cms\Core\Content\FormBuilder\Event\FormBuilderSendEvent;
  4. use Shopware\Core\Framework\Event\BusinessEventCollector;
  5. use Shopware\Core\Framework\Event\BusinessEventCollectorEvent;
  6. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  7. class BusinessEventCollectorSubscriber implements EventSubscriberInterface
  8. {
  9.     private BusinessEventCollector $businessEventCollector;
  10.     public function __construct(BusinessEventCollector $businessEventCollector) {
  11.         $this->businessEventCollector $businessEventCollector;
  12.     }
  13.     public static function getSubscribedEvents(): array
  14.     {
  15.         return [
  16.             BusinessEventCollectorEvent::NAME => ['onAddFormBuilderEvent'1000],
  17.         ];
  18.     }
  19.     public function onAddFormBuilderEvent(BusinessEventCollectorEvent $event): void
  20.     {
  21.         $collection $event->getCollection();
  22.         $definition $this->businessEventCollector->define(FormBuilderSendEvent::class);
  23.         if (!$definition) {
  24.             return;
  25.         }
  26.         $collection->set($definition->getName(), $definition);
  27.     }
  28. }