public function setRepositoryAddress($address) { if ($repository = $this->getRepository()) { if ($primaryContact = $repository->getPrimaryContact()) { if (is_null($primaryContact->getStreetAddress())) { $primaryContact->setStreetAddress($address); $primaryContact->save(); } } else { $contactInformation = new QubitContactInformation(); $contactInformation->setStreetAddress($address); $contactInformation->setPrimaryContact(true); $contactInformation->setActorId($repository->id); $contactInformation->save(); } } }