custom/static-plugins/SamsonCustomer/src/Subscriber/BusinessEventSubscriber.php line 50

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Samson\Subscriber;
  3. /***
  4.  *
  5.  * This file is part of the "SAMSON Shop" project.
  6.  *
  7.  * For the full copyright and license information, please read the
  8.  * LICENSE.txt file that was distributed with this source code.
  9.  *
  10.  *  (c) 2022
  11.  *
  12.  ***/
  13. use Samson\Event\C4CLeadCreationFinishedEvent;
  14. use Samson\Event\CustomerAdminActivationEvent;
  15. use Samson\Event\CustomerRegistrationFinishedEvent;
  16. use Samson\Event\NE53NewsletterConfirmEvent;
  17. use Samson\Event\NE53NewsletterRegisterEvent;
  18. use Samson\Event\NE53NewsletterUnsubscribeEvent;
  19. use Samson\Event\ReviewWrittenEvent;
  20. use Samson\Event\Sap\SapCustomerAddressSynchronizationEvent;
  21. use Samson\Event\Sap\SapCustomerRegistrationErrorEvent;
  22. use Samson\Event\Sap\SapPriceUpdateEvent;
  23. use Samson\Event\Sap\SapProductCreateEvent;
  24. use Samson\Event\Sap\SapProductUpdateEvent;
  25. use Samson\Event\TradeFairProductSelectionEvent;
  26. use Samson\Event\UserInvitedEvent;
  27. use Shopware\Core\Framework\Event\BusinessEventCollector;
  28. use Shopware\Core\Framework\Event\BusinessEventCollectorEvent;
  29. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  30. class BusinessEventSubscriber implements EventSubscriberInterface
  31. {
  32.     private BusinessEventCollector $businessEventCollector;
  33.     public function __construct(BusinessEventCollector $businessEventCollector)
  34.     {
  35.         $this->businessEventCollector $businessEventCollector;
  36.     }
  37.     public static function getSubscribedEvents(): array
  38.     {
  39.         return [
  40.             BusinessEventCollectorEvent::NAME => 'onBusinessEventCollectorEvent',
  41.         ];
  42.     }
  43.     public function onBusinessEventCollectorEvent(BusinessEventCollectorEvent $event): void
  44.     {
  45.         $events = [
  46.             ReviewWrittenEvent::class => ReviewWrittenEvent::$eventName,
  47.             SapPriceUpdateEvent::class => SapPriceUpdateEvent::EVENT_NAME,
  48.             SapProductCreateEvent::class => SapProductCreateEvent::EVENT_NAME,
  49.             SapProductUpdateEvent::class => SapProductUpdateEvent::EVENT_NAME,
  50.             SapCustomerRegistrationErrorEvent::class => SapCustomerRegistrationErrorEvent::EVENT_NAME,
  51.             SapCustomerAddressSynchronizationEvent::class => SapCustomerAddressSynchronizationEvent::EVENT_NAME,
  52.             CustomerRegistrationFinishedEvent::class => CustomerRegistrationFinishedEvent::EVENT_NAME,
  53.             TradeFairProductSelectionEvent::class => TradeFairProductSelectionEvent::EVENT_NAME,
  54.             C4CLeadCreationFinishedEvent::class => C4CLeadCreationFinishedEvent::EVENT_NAME,
  55.             CustomerAdminActivationEvent::class => CustomerAdminActivationEvent::EVENT_NAME,
  56.             NE53NewsletterConfirmEvent::class => NE53NewsletterConfirmEvent::EVENT_NAME,
  57.             NE53NewsletterRegisterEvent::class => NE53NewsletterRegisterEvent::EVENT_NAME,
  58.             NE53NewsletterUnsubscribeEvent::class => NE53NewsletterUnsubscribeEvent::EVENT_NAME,
  59.             UserInvitedEvent::class => UserInvitedEvent::EVENT_NAME
  60.         ];
  61.         foreach ($events as $class => $eventName) {
  62.             $definition $this->businessEventCollector->define($class$eventName);
  63.             $event->getCollection()->set($eventName$definition);
  64.         }
  65.     }
  66. }