custom/plugins/CogiAdvancedContactForm/src/Subscriber/BusinessEventCollectorSubscriber.php line 25

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Cogi\CogiAdvancedContactForm\Subscriber;
  3. use Cogi\CogiAdvancedContactForm\Core\Event\CogiAdvancedContactFormSubmitEvent;
  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()
  14.     {
  15.         return [
  16.             BusinessEventCollectorEvent::NAME => ['onAddCogiFormEvents'1000],
  17.         ];
  18.     }
  19.     public function onAddCogiFormEvents(BusinessEventCollectorEvent $event): void
  20.     {
  21.         $collection $event->getCollection();
  22.         $eventClasses = [
  23.             CogiAdvancedContactFormSubmitEvent::class,
  24.         ];
  25.         foreach($eventClasses as $eventClass) {
  26.             $definition $this->businessEventCollector->define($eventClass);
  27.             if (!$definition) {
  28.                 continue;
  29.             }
  30.             $collection->set($definition->getName(), $definition);
  31.         }
  32.     }
  33. }