Adapter/ShopwareAdapter/ResponseParser/Customer/CustomerResponseParser.php
public function parse(array $entry)
    {
        $entry['salutation'] = strtolower($entry['salutation']);

        $shopIdentifier = $this->getIdentifier((string) $entry['shopId'], Shop::TYPE);

        $languageIdentifier = $this->getLanguageIdentifier($entry);
        if (null === $languageIdentifier) {
            $this->logger->warning('no customer language found');

            return null;
        }

        $customerGroup = $this->getCustomerGroup($entry);
        if (null === $customerGroup) {
            $this->logger->warning('no customer group found');

            return null;
        }

        $customerGroupIdentifier = $this->getIdentifier((string) $customerGroup->getId(), CustomerGroup::TYPE);

        if ($entry['salutation'] === 'mr' || $entry['salutation'] === 'herr') {
            $gender = Customer::GENDER_MALE;
        } elseif ($entry['salutation'] === 'ms' || $entry['salutation'] === 'frau') {
            $gender = Customer::GENDER_FEMALE;
        } else {
            $gender = null;
        }

        if (empty($entry['birthday'])) {
            $birthday = null;
        } else {
            $birthday = DateTimeImmutable::createFromMutable($entry['birthday']);

            if (!($birthday instanceof DateTimeImmutable)) {
                $birthday = null;
            }
        }

        if (empty($entry['title'])) {
            $entry['title'] = null;
        }

        $customer = new Customer();
        $customer->setBirthday($birthday);
        $customer->setType($this->getCustomerTypeId($entry['accountMode']));
        $customer->setEmail($entry['email']);
        $customer->setFirstname($entry['firstname']);
        $customer->setLastname($entry['lastname']);
        $customer->setNumber($entry['number']);
        $customer->setGender($gender);
        $customer->setTitle($entry['title']);
        $customer->setShopIdentifier($shopIdentifier);
        $customer->setLanguageIdentifier($languageIdentifier);
        $customer->setCustomerGroupIdentifier($customerGroupIdentifier);

        /**
         * @var EntityRepository $newsletterRepository
         */
        $newsletterRepository = $this->entityManager->getRepository(Address::class);

        /**
         * @var null|Address $newsletter
         */
        $newsletter = $newsletterRepository->findOneBy(['email' => $entry['email']]);

        if ($newsletter !== null) {
            $customer->setNewsletter(true);

            if (null !== $newsletter->getAdded()) {
                $customer->setNewsletterAgreementDate(DateTimeImmutable::createFromMutable($newsletter->getAdded()));
            }
        }

        return $customer;
    }
public function parse(array $entry)
    {
        $entry['salutation'] = strtolower($entry['salutation']);

        $shopIdentifier = $this->getIdentifier((string) $entry['shopId'], Shop::TYPE);

        $languageIdentifier = $this->getLanguageIdentifier($entry);
        if (null === $languageIdentifier) {
            $this->logger->warning('no customer language found');

            return null;
        }

        $customerGroup = $this->getCustomerGroup($entry);
        if (null === $customerGroup) {
            $this->logger->warning('no customer group found');

            return null;
        }

        $customerGroupIdentifier = $this->getIdentifier((string) $customerGroup->getId(), CustomerGroup::TYPE);

        if ($entry['salutation'] === 'mr' || $entry['salutation'] === 'herr') {
            $gender = Customer::GENDER_MALE;
        } elseif ($entry['salutation'] === 'ms' || $entry['salutation'] === 'frau') {
            $gender = Customer::GENDER_FEMALE;
        } else {
            $gender = null;
        }

        if (empty($entry['birthday'])) {
            $birthday = null;
        } else {
            $birthday = DateTimeImmutable::createFromMutable($entry['birthday']);

            if (!($birthday instanceof DateTimeImmutable)) {
                $birthday = null;
            }
        }

        if (empty($entry['title'])) {
            $entry['title'] = null;
        }

        $customer = new Customer();
        $customer->setBirthday($birthday);
        $customer->setType($this->getCustomerTypeId($entry['accountMode']));
        $customer->setEmail($entry['email']);
        $customer->setFirstname($entry['firstname']);
        $customer->setLastname($entry['lastname']);
        $customer->setNumber($entry['number']);
        $customer->setGender($gender);
        $customer->setTitle($entry['title']);
        $customer->setShopIdentifier($shopIdentifier);
        $customer->setLanguageIdentifier($languageIdentifier);
        $customer->setCustomerGroupIdentifier($customerGroupIdentifier);

        /**
         * @var EntityRepository $newsletterRepository
         */
        $newsletterRepository = $this->entityManager->getRepository(Address::class);

        /**
         * @var null|Address $newsletter
         */
        $newsletter = $newsletterRepository->findOneBy(['email' => $entry['email']]);

        if ($newsletter !== null) {
            $customer->setNewsletter(true);

            if (null !== $newsletter->getAdded()) {
                $customer->setNewsletterAgreementDate(DateTimeImmutable::createFromMutable($newsletter->getAdded()));
            }
        }

        return $customer;
    }
public function parse ( array $ entry ) { $ entry [ 'salutation' ] = strtolower ( $ entry [ 'salutation' ] ) ; $ shopIdentifier = $ this -> getIdentifier ( ( string ) $ entry [ 'shopId' ] , Shop :: TYPE ) ; $ languageIdentifier = $ this -> getLanguageIdentifier ( $ entry ) ; if ( null === $ languageIdentifier ) { $ this -> logger -> warning ( 'no customer language found' ) ; return null ; } $ customerGroup = $ this -> getCustomerGroup ( $ entry ) ; if ( null === $ customerGroup ) { $ this -> logger -> warning ( 'no customer group found' ) ; return null ; } $ customerGroupIdentifier = $ this -> getIdentifier ( ( string ) $ customerGroup -> getId ( ) , CustomerGroup :: TYPE ) ; if ( $ entry [ 'salutation' ] === 'mr' || $ entry [ 'salutation' ] === 'herr' ) { $ gender = Customer :: GENDER_MALE ; } elseif ( $ entry [ 'salutation' ] === 'ms' || $ entry [ 'salutation' ] === 'frau' ) { $ gender = Customer :: GENDER_FEMALE ; } else { $ gender = null ; } if ( empty ( $ entry [ 'birthday' ] ) ) { $ birthday = null ; } else { $ birthday = DateTimeImmutable :: createFromMutable ( $ entry [ 'birthday' ] ) ; if ( ! ( $ birthday instanceof DateTimeImmutable ) ) { $ birthday = null ; } } if ( empty ( $ entry [ 'title' ] ) ) { $ entry [ 'title' ] = null ; } $ customer = new Customer ( ) ; $ customer -> setBirthday ( $ birthday ) ; $ customer -> setType ( $ this -> getCustomerTypeId ( $ entry [ 'accountMode' ] ) ) ; $ customer -> setEmail ( $ entry [ 'email' ] ) ; $ customer -> setFirstname ( $ entry [ 'firstname' ] ) ; $ customer -> setLastname ( $ entry [ 'lastname' ] ) ; $ customer -> setNumber ( $ entry [ 'number' ] ) ; $ customer -> setGender ( $ gender ) ; $ customer -> setTitle ( $ entry [ 'title' ] ) ; $ customer -> setShopIdentifier ( $ shopIdentifier ) ; $ customer -> setLanguageIdentifier ( $ languageIdentifier ) ; $ customer -> setCustomerGroupIdentifier ( $ customerGroupIdentifier ) ; /**
         * @var EntityRepository $newsletterRepository
         */ $ newsletterRepository = $ this -> entityManager -> getRepository ( Address :: class ) ; /**
         * @var null|Address $newsletter
         */ $ newsletter = $ newsletterRepository -> findOneBy ( [ 'email' => $ entry [ 'email' ] ] ) ; if ( $ newsletter !== null ) { $ customer -> setNewsletter ( true ) ; if ( null !== $ newsletter -> getAdded ( ) ) { $ customer -> setNewsletterAgreementDate ( DateTimeImmutable :: createFromMutable ( $ newsletter -> getAdded ( ) ) ) ; } } return $ customer ; }
{@inheritdoc}
{