/** * Check if user has a contact details (mobile or phone). * @param InstitutionUser $user * @return InstitutionUser * @author Chaztine Blance */ public function initializeContactDetails($parentObject, $types, Country $country = null) { $types = array_flip($types); foreach ($parentObject->getContactDetails() as $contact) { unset($types[$contact->getType()]); } foreach ($types as $type => $dummy) { $number = new ContactDetail(); $number->setType($type); if ($country) { $number->setCountryCode($country->getCountryCode()); $number->setCountry($country); } $parentObject->addContactDetail($number); } return $parentObject; }