custom/plugins/WabsPIM/src/Subscriber/BusinessEventCollectorSubscriber.php line 27

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