custom/static-plugins/NdSRS/src/Subscriber/BusinessEventCollectorSubscriber.php line 29

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Nd\Srs\Subscriber;
  3. use Nd\Srs\Core\Framework\Event\CancelEvent;
  4. use Nd\Srs\Core\Framework\Event\OnlineAccountCreatedEvent;
  5. use Nd\Srs\Core\Framework\Event\ReturnEvent;
  6. use Nd\Srs\Core\Framework\Event\TrackingCodeAddedEvent;
  7. use Shopware\Core\Framework\Event\BusinessEventCollector;
  8. use Shopware\Core\Framework\Event\BusinessEventCollectorEvent;
  9. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  10. class BusinessEventCollectorSubscriber implements EventSubscriberInterface
  11. {
  12.     private BusinessEventCollector $businessEventCollector;
  13.     public function __construct(BusinessEventCollector $businessEventCollector) {
  14.         $this->businessEventCollector $businessEventCollector;
  15.     }
  16.     public static function getSubscribedEvents()
  17.     {
  18.         return [
  19.             BusinessEventCollectorEvent::NAME => ['addSrsEvents'1000],
  20.         ];
  21.     }
  22.     public function addSrsEvents(BusinessEventCollectorEvent $event): void
  23.     {
  24.         $collection $event->getCollection();
  25.         $definitions = [
  26.             $this->businessEventCollector->define(TrackingCodeAddedEvent::class),
  27.             $this->businessEventCollector->define(OnlineAccountCreatedEvent::class),
  28.             $this->businessEventCollector->define(CancelEvent::class),
  29.             $this->businessEventCollector->define(ReturnEvent::class)];
  30.         foreach($definitions as $definition){
  31.             if (!$definition) {
  32.                 continue;
  33.             }
  34.             $collection->set($definition->getName(), $definition);
  35.         }
  36.     }
  37. }