/** * Create account owner with type = 'other' * and returns array * * @param ClientAdditionalContact $otherContact * @return array */ private function createOtherAccountOwner(ClientAdditionalContact $otherContact) { /** @var ClientAdditionalContactRepository $repo */ $repo = $this->em->getRepository('WealthbotClientBundle:ClientAdditionalContact'); $exist = $repo->findOneBy(array('client_id' => $this->client->getId(), 'first_name' => $otherContact->getFirstName(), 'middle_name' => $otherContact->getMiddleName(), 'last_name' => $otherContact->getLastName(), 'relationship' => $otherContact->getRelationship(), 'type' => ClientAdditionalContact::TYPE_OTHER)); if ($exist) { $otherContact = $exist; } $otherContact->setType(ClientAccountOwner::OWNER_TYPE_OTHER); $otherContact->setClient($this->client); $this->em->persist($otherContact); $this->em->flush(); $owner = array('owner_type' => ClientAccountOwner::OWNER_TYPE_OTHER, 'owner_contact_id' => $otherContact->getId()); return $owner; }
public function setSpouse(ClientAdditionalContact $spouse) { if ($spouse->getType() !== ClientAdditionalContact::TYPE_SPOUSE) { throw new \InvalidArgumentException(sprintf('Invalid client spouse type field value: %s', $spouse->getType())); } $currSpouse = $this->getSpouse(); if ($currSpouse) { $currSpouse->setFirstName($spouse->getFirstName()); $currSpouse->setMiddleName($spouse->getMiddleName()); $currSpouse->setLastName($spouse->getLastName()); $currSpouse->setBirthDate($spouse->getBirthDate()); } else { $this->addAdditionalContact($spouse); } return $this; }