custom/plugins/CoeRechnungsMailSw6/src/Subscriber/CustomerSubscriber.php line 48

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace CoeRechnungsMailSw6\Subscriber;
  3. use CoeRechnungsMailSw6\CoeRechnungsMailSw6;
  4. use Shopware\Core\Checkout\Customer\CustomerEvents;
  5. use Shopware\Core\Framework\Event\DataMappingEvent;
  6. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  7. use Shopware\Core\System\SystemConfig\SystemConfigService;
  8. /**
  9.  * Class CustomerSubscriber
  10.  * This subscriber subscribes to events which deals with the registration-process of the customer.
  11.  * Like adding fields to the database during the registration.
  12.  * @package CoeRechnungsMailSw6\Subscriber
  13.  * @author Jeffry Block <jeffry.block@codeenterprise.de>
  14.  */
  15. Class CustomerSubscriber implements EventSubscriberInterface{
  16.     /** @var SystemConfigService $systemConfigService*/
  17.     private $systemConfigService;
  18.     /**
  19.      * CustomerSubscriber constructor.
  20.      * @param SystemConfigService $systemConfigService
  21.      */
  22.     function __construct(SystemConfigService $systemConfigService)
  23.     {
  24.         $this -> systemConfigService $systemConfigService;
  25.     }
  26.     /**
  27.      * @return array
  28.      * @author Jeffry Block <jeffry.block@codeenterprise.de>
  29.      */
  30.     public static function getSubscribedEvents(): array
  31.     {
  32.         return [
  33.             CustomerEvents::MAPPING_REGISTER_CUSTOMER => 'onMapCustomerRegistrationData',
  34.             CustomerEvents::MAPPING_CUSTOMER_PROFILE_SAVE => 'onMapCustomerRegistrationData',
  35.         ];
  36.     }
  37.     /**
  38.      * @param DataMappingEvent $event
  39.      * @author Jeffry Block <jeffry.block@codeenterprise.de>
  40.      */
  41.     public function onMapCustomerRegistrationData(DataMappingEvent $event): void
  42.     {
  43.         $documentMail $event->getInput()->get("documentMail""");
  44.         $output $event -> getOutput();
  45.         $output["customFields"] =  [
  46.             CoeRechnungsMailSw6::$field_name_mail => $documentMail,
  47.             CoeRechnungsMailSw6::$field_name_active => str_contains($documentMail"@")
  48.         ];
  49.         $event-> setOutput($output);
  50.     }
  51. }