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

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