custom/plugins/bp-plugin-shopware6-api2-1.3.0/src/EventSubscriber/MappingRegisterCustomer.php line 21

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace BetterPayment\EventSubscriber;
  3. use BetterPayment\Installer\CustomFieldInstaller;
  4. use Shopware\Core\Checkout\Customer\CustomerEvents;
  5. use Shopware\Core\Framework\Event\DataMappingEvent;
  6. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  7. class MappingRegisterCustomer implements EventSubscriberInterface
  8. {
  9.     public static function getSubscribedEvents(): array
  10.     {
  11.         return [
  12.             CustomerEvents::MAPPING_REGISTER_CUSTOMER => 'addCustomField',
  13.             CustomerEvents::MAPPING_CUSTOMER_PROFILE_SAVE => 'addCustomField'
  14.         ];
  15.     }
  16.     public function addCustomField(DataMappingEvent $event): bool
  17.     {
  18.         $input $event->getInput();
  19.         $output $event->getOutput();
  20.         $gender $input->get(CustomFieldInstaller::CUSTOMER_GENDER);
  21.         $output['customFields'] = [CustomFieldInstaller::CUSTOMER_GENDER => $gender];
  22.         $event->setOutput($output);
  23.         return true;
  24.     }
  25. }