/** * @param Contact $object * * @return array */ public function extract($object) { $this->prepare($object); $values = $this->extractByValue($object); unset($values['phone']); foreach ($object->getPhone() as $phone) { $values['phone'][$phone->getType()->getId()]['phone'] = $phone->getPhone(); } unset($values['address']); foreach ($object->getAddress() as $address) { if ($address->getType()->getId() === AddressType::ADDRESS_TYPE_MAIL) { $values['address']['address'] = $address->getAddress(); $values['address']['zipCode'] = $address->getZipCode(); $values['address']['city'] = $address->getCity(); $values['address']['country'] = $address->getCountry(); } } unset($values['community']); foreach ($object->getCommunity() as $community) { $values['community'][$community->getType()->getId()]['community'] = $community->getCommunity(); } unset($values['profile']); $values['profile']['visible'] = !is_null($object->getProfile()) ? $object->getProfile()->getVisible() : null; $values['profile']['description'] = !is_null($object->getProfile()) ? $object->getProfile()->getDescription() : null; /** * Set the contact organisation */ $contactService = new ContactService(); $contactService->setContact($object); if (!is_null($object->getContactOrganisation())) { $organisationService = new OrganisationService(); $organisationService->setOrganisation($object->getContactOrganisation()->getOrganisation()); $values['contact_organisation']['organisation'] = $organisationService->parseOrganisationWithBranch($contactService->getContact()->getContactOrganisation()->getBranch()); if (!is_null($object->getContactOrganisation())) { $values['contact_organisation']['country'] = $object->getContactOrganisation()->getOrganisation()->getCountry()->getId(); } } return $values; }
/** * @param ContactService $contactService * * @return string */ public function parseContact(ContactService $contactService) { return $this->getRenderer()->render('contact/partial/contact', ['contact' => $contactService->getContact()]); }