/** * 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'); } }
/** * 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; } }
/** * 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; }
/** * 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); } } }
/** * 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; }