예제 #1
0
 /**
  * Compares an order-address response with its origin entities.
  *
  * @param OrderAddressInterface $orderAddress
  * @param Address $address
  * @param ContactInterface $contact
  * @param AccountInterface $account
  */
 protected function checkOrderAddress($orderAddress, Address $address, ContactInterface $contact, AccountInterface $account = null)
 {
     // Contact
     $this->assertEquals($contact->getFirstName(), $orderAddress->firstName);
     $this->assertEquals($contact->getLastName(), $orderAddress->lastName);
     if ($contact->getTitle() !== null) {
         $this->assertEquals($contact->getTitle()->getTitle(), $orderAddress->title);
     }
     // Address
     $this->assertEqualsIfExists($address->getStreet(), $orderAddress, 'street');
     $this->assertEqualsIfExists($address->getAddition(), $orderAddress, 'addition');
     $this->assertEqualsIfExists($address->getNumber(), $orderAddress, 'number');
     $this->assertEqualsIfExists($address->getCity(), $orderAddress, 'city');
     $this->assertEqualsIfExists($address->getZip(), $orderAddress, 'zip');
     $this->assertEqualsIfExists($address->getCountry()->getName(), $orderAddress, 'country');
     $this->assertEqualsIfExists($address->getPostboxNumber(), $orderAddress, 'postboxNumber');
     $this->assertEqualsIfExists($address->getPostboxCity(), $orderAddress, 'postboxCity');
     $this->assertEqualsIfExists($address->getPostboxPostcode(), $orderAddress, 'postboxPostcode');
     // Account
     if ($account) {
         $this->assertEqualsIfExists($account->getName(), $orderAddress, 'accountName');
         $this->assertEqualsIfExists($account->getUid(), $orderAddress, 'uid');
     }
 }
예제 #2
0
 /**
  * Returns the data needed for the account list-sidebar.
  *
  * @param ContactInterface $contact
  *
  * @return array
  */
 protected function parseMainContact(ContactInterface $contact)
 {
     if ($contact) {
         $data = [];
         $data['id'] = $contact->getId();
         $data['fullName'] = $contact->getFullName();
         $data['phone'] = $contact->getMainPhone();
         $data['email'] = $contact->getMainEmail();
         return $data;
     } else {
         return null;
     }
 }
예제 #3
0
 /**
  * Creates account contact relation.
  *
  * @param AccountInterface $account
  * @param ContactInterface $contact
  * @param bool $isMain
  *
  * @return AccountContact
  */
 protected function createAccountContact(AccountInterface $account, ContactInterface $contact, $isMain = true)
 {
     $accountContact = new AccountContact();
     $accountContact->setAccount($account);
     $accountContact->setContact($contact);
     $accountContact->setMain($isMain);
     $this->contact->addAccountContact($accountContact);
     $this->em->persist($accountContact);
     return $accountContact;
 }
예제 #4
0
 /**
  * Sets contact data to address data.
  *
  * @param array $addressData
  * @param ContactInterface $contact
  */
 public function mergeContactIntoAddressData(array &$addressData, ContactInterface $contact)
 {
     $addressData['firstName'] = $contact->getFirstName();
     $addressData['lastName'] = $contact->getLastName();
     $addressData['fullName'] = $contact->getFullName();
     $addressData['salutation'] = $contact->getSalutation();
     $addressData['formOfAddress'] = $contact->getFormOfAddress();
     if ($contact->getTitle() !== null) {
         $addressData['title'] = $contact->getTitle()->getTitle();
     }
 }
 /**
  * @param ContactInterface $contact
  */
 protected function persistContactAddress(ContactInterface $contact)
 {
     /** @var ContactAddress $contactAddress */
     foreach ($contact->getContactAddresses() as $contactAddress) {
         $this->entityManager->persist($contactAddress);
         if ($address = $contactAddress->getAddress()) {
             if (!$address->getAddressType()) {
                 $addressType = $this->entityManager->getRepository(AddressType::class)->find(1);
                 $address->setAddressType($addressType);
             }
             $this->entityManager->persist($address);
         }
     }
 }
예제 #6
0
 /**
  * Gets email address of a contact
  *
  * @param ContactInterface $contact
  * @param bool $useFallback
  *
  * @return string|null
  */
 public function getEmailAddressOfContact(ContactInterface $contact, $useFallback = true)
 {
     // take contacts main-email
     $contactMainEmail = $contact->getMainEmail();
     if ($contact && $contactMainEmail) {
         return $contactMainEmail;
     }
     // fallback take contact's main-account main-email
     $account = $contact->getMainAccount();
     if ($useFallback && $account) {
         return $this->getEmailAddressOfAccount($account);
     }
     return null;
 }