custom/plugins/WbfkOffer/src/Event/Flow/BusinessEventCollectorSubscriber.php line 25

Open in your IDE?
  1. <?php
  2. namespace Wbfk\Offer\Event\Flow;
  3. use Shopware\Core\Framework\Event\BusinessEventCollector;
  4. use Shopware\Core\Framework\Event\BusinessEventCollectorEvent;
  5. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  6. class BusinessEventCollectorSubscriber implements EventSubscriberInterface
  7. {
  8.     private BusinessEventCollector $businessEventCollector;
  9.     public function __construct(BusinessEventCollector $businessEventCollector)
  10.     {
  11.         $this->businessEventCollector $businessEventCollector;
  12.     }
  13.     public static function getSubscribedEvents(): array
  14.     {
  15.         return [
  16.             BusinessEventCollectorEvent::NAME => ['onOfferEvent'1000],
  17.         ];
  18.     }
  19.     public function onOfferEvent(BusinessEventCollectorEvent $event): void
  20.     {
  21.         $this->addDefinition($eventOfferEventApproved::class);
  22.         $this->addDefinition($eventOfferEventApprovedInternal::class);
  23.         $this->addDefinition($eventOfferEventRequested::class);
  24.     }
  25.     private function addDefinition(BusinessEventCollectorEvent $eventstring $eventName): void
  26.     {
  27.         $collection $event->getCollection();
  28.         $definition $this->businessEventCollector->define($eventName);
  29.         if (!$definition) {
  30.             return;
  31.         }
  32.         $collection->set($definition->getName(), $definition);
  33.     }
  34. }