custom/plugins/NetiNextEasyCoupon/src/Subscriber/BusinessEvent.php line 29

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace NetInventors\NetiNextEasyCoupon\Subscriber;
  4. use NetInventors\NetiNextEasyCoupon\Constants\BusinessEventsConstants;
  5. use Shopware\Core\Framework\Event\BusinessEventCollector;
  6. use Shopware\Core\Framework\Event\BusinessEventCollectorEvent;
  7. use Shopware\Core\Framework\Event\BusinessEventDefinition;
  8. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  9. class BusinessEvent implements EventSubscriberInterface
  10. {
  11.     protected BusinessEventCollector $collector;
  12.     public function __construct(BusinessEventCollector $collector)
  13.     {
  14.         $this->collector $collector;
  15.     }
  16.     public static function getSubscribedEvents(): array
  17.     {
  18.         return [
  19.             BusinessEventCollectorEvent::NAME => 'onRegisterEvent',
  20.         ];
  21.     }
  22.     public function onRegisterEvent(BusinessEventCollectorEvent $event)
  23.     {
  24.         foreach (BusinessEventsConstants::EVENT_CLASSES as $class) {
  25.             $eventDefinition $this->collector->define($class);
  26.             if ($eventDefinition instanceof BusinessEventDefinition) {
  27.                 $event->getCollection()->set($class$eventDefinition);
  28.             }
  29.         }
  30.     }
  31. }