vendor/dvdw/platform-choice/src/Checkout/Customer/Subscriber/RegisterDataMappingSubscriber.php line 16

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Dvdw\PlatformChoice\Checkout\Customer\Subscriber;
  3. use Shopware\Core\Checkout\Customer\CustomerEvents;
  4. use Shopware\Core\Framework\Event\DataMappingEvent;
  5. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  6. class RegisterDataMappingSubscriber implements EventSubscriberInterface
  7. {
  8.     public static function getSubscribedEvents(): iterable
  9.     {
  10.         return [CustomerEvents::MAPPING_REGISTER_CUSTOMER => 'updateCustomerGroup'];
  11.     }
  12.     public function updateCustomerGroup(DataMappingEvent $event): void
  13.     {
  14.         $customer $event->getOutput();
  15.         $bag $event->getInput();
  16.         if (!isset($customer['groupId']) || ($groupId $bag->get('groupId')) === null) {
  17.             return;
  18.         }
  19.         $customer['groupId'] = $groupId;
  20.         $event->setOutput($customer);
  21.     }
  22. }