custom/plugins/MolliePayments/src/Compatibility/Bundles/FlowBuilder/Subscriber/BusinessEventCollectorSubscriber.php line 64

Open in your IDE?
  1. <?php
  2. namespace Kiener\MolliePayments\Compatibility\Bundles\FlowBuilder\Subscriber;
  3. use Kiener\MolliePayments\Compatibility\Bundles\FlowBuilder\Events\Checkout\OrderCanceledEvent;
  4. use Kiener\MolliePayments\Compatibility\Bundles\FlowBuilder\Events\Checkout\OrderFailedEvent;
  5. use Kiener\MolliePayments\Compatibility\Bundles\FlowBuilder\Events\Checkout\OrderSuccessEvent;
  6. use Kiener\MolliePayments\Compatibility\Bundles\FlowBuilder\Events\Refund\RefundStartedEvent;
  7. use Kiener\MolliePayments\Compatibility\Bundles\FlowBuilder\Events\Subscription\SubscriptionCancelledEvent;
  8. use Kiener\MolliePayments\Compatibility\Bundles\FlowBuilder\Events\Subscription\SubscriptionEndedEvent;
  9. use Kiener\MolliePayments\Compatibility\Bundles\FlowBuilder\Events\Subscription\SubscriptionPausedEvent;
  10. use Kiener\MolliePayments\Compatibility\Bundles\FlowBuilder\Events\Subscription\SubscriptionRemindedEvent;
  11. use Kiener\MolliePayments\Compatibility\Bundles\FlowBuilder\Events\Subscription\SubscriptionRenewedEvent;
  12. use Kiener\MolliePayments\Compatibility\Bundles\FlowBuilder\Events\Subscription\SubscriptionResumedEvent;
  13. use Kiener\MolliePayments\Compatibility\Bundles\FlowBuilder\Events\Subscription\SubscriptionSkippedEvent;
  14. use Kiener\MolliePayments\Compatibility\Bundles\FlowBuilder\Events\Subscription\SubscriptionStartedEvent;
  15. use Kiener\MolliePayments\Compatibility\Bundles\FlowBuilder\Events\WebhookReceivedEvent;
  16. use Kiener\MolliePayments\Compatibility\Bundles\FlowBuilder\Events\WebhookStatusReceived\WebhookReceivedAuthorizedEvent;
  17. use Kiener\MolliePayments\Compatibility\Bundles\FlowBuilder\Events\WebhookStatusReceived\WebhookReceivedCancelledEvent;
  18. use Kiener\MolliePayments\Compatibility\Bundles\FlowBuilder\Events\WebhookStatusReceived\WebhookReceivedChargebackEvent;
  19. use Kiener\MolliePayments\Compatibility\Bundles\FlowBuilder\Events\WebhookStatusReceived\WebhookReceivedCompletedEvent;
  20. use Kiener\MolliePayments\Compatibility\Bundles\FlowBuilder\Events\WebhookStatusReceived\WebhookReceivedExpiredEvent;
  21. use Kiener\MolliePayments\Compatibility\Bundles\FlowBuilder\Events\WebhookStatusReceived\WebhookReceivedFailedEvent;
  22. use Kiener\MolliePayments\Compatibility\Bundles\FlowBuilder\Events\WebhookStatusReceived\WebhookReceivedPaidEvent;
  23. use Kiener\MolliePayments\Compatibility\Bundles\FlowBuilder\Events\WebhookStatusReceived\WebhookReceivedPartialRefundedEvent;
  24. use Kiener\MolliePayments\Compatibility\Bundles\FlowBuilder\Events\WebhookStatusReceived\WebhookReceivedPendingEvent;
  25. use Kiener\MolliePayments\Compatibility\Bundles\FlowBuilder\Events\WebhookStatusReceived\WebhookReceivedRefundedEvent;
  26. use Shopware\Core\Framework\Event\BusinessEventCollector;
  27. use Shopware\Core\Framework\Event\BusinessEventCollectorEvent;
  28. use Shopware\Core\Framework\Event\BusinessEventDefinition;
  29. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  30. class BusinessEventCollectorSubscriber implements EventSubscriberInterface
  31. {
  32.     /**
  33.      * @var BusinessEventCollector
  34.      */
  35.     private $businessEventCollector;
  36.     /**
  37.      * @param BusinessEventCollector $businessEventCollector
  38.      */
  39.     public function __construct(BusinessEventCollector $businessEventCollector)
  40.     {
  41.         $this->businessEventCollector $businessEventCollector;
  42.     }
  43.     /**
  44.      * @return array<mixed>
  45.      */
  46.     public static function getSubscribedEvents()
  47.     {
  48.         return [
  49.             BusinessEventCollectorEvent::NAME => ['onAddEvent'1000],
  50.         ];
  51.     }
  52.     /**
  53.      * @param BusinessEventCollectorEvent $event
  54.      * @return void
  55.      */
  56.     public function onAddEvent(BusinessEventCollectorEvent $event): void
  57.     {
  58.         $collection $event->getCollection();
  59.         $events = [
  60.             OrderSuccessEvent::class,
  61.             OrderFailedEvent::class,
  62.             OrderCanceledEvent::class,
  63.             # --------------------------------------------
  64.             WebhookReceivedEvent::class,
  65.             # --------------------------------------------
  66.             WebhookReceivedPaidEvent::class,
  67.             WebhookReceivedFailedEvent::class,
  68.             WebhookReceivedExpiredEvent::class,
  69.             WebhookReceivedCancelledEvent::class,
  70.             WebhookReceivedPendingEvent::class,
  71.             WebhookReceivedCompletedEvent::class,
  72.             WebhookReceivedAuthorizedEvent::class,
  73.             WebhookReceivedChargebackEvent::class,
  74.             WebhookReceivedRefundedEvent::class,
  75.             WebhookReceivedPartialRefundedEvent::class,
  76.             # --------------------------------------------
  77.             RefundStartedEvent::class,
  78.             # --------------------------------------------
  79.             SubscriptionStartedEvent::class,
  80.             SubscriptionEndedEvent::class,
  81.             SubscriptionPausedEvent::class,
  82.             SubscriptionResumedEvent::class,
  83.             SubscriptionSkippedEvent::class,
  84.             SubscriptionCancelledEvent::class,
  85.             SubscriptionRemindedEvent::class,
  86.             SubscriptionRenewedEvent::class,
  87.         ];
  88.         foreach ($events as $event) {
  89.             /** @var BusinessEventDefinition $definition */
  90.             $definition $this->businessEventCollector->define($event);
  91.             $collection->set($definition->getName(), $definition);
  92.         }
  93.     }
  94. }