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