public function setIdentifierWithCodes($identifier, $options) { $this->setIdentifier($identifier); if ($repository = QubitRepository::getById($this->getRepositoryId())) { // if the repository doesn't already have a code, set it using the <unitid repositorycode=""> value if (isset($options['repositorycode'])) { if (!$repository->getIdentifier()) { $repository->setIdentifier($options['repositorycode']); $repository->save(); } } // if the repository doesn't already have an country code, set it using the <unitid countrycode=""> value if (isset($options['countrycode'])) { if (!$repository->getCountryCode()) { if ($primaryContact = $repository->getPrimaryContact()) { $primaryContact->setCountryCode(strtoupper($options['countrycode'])); $primaryContact->save(); } else { if (count($contacts = $repository->getContactInformation()) > 0) { $contacts[0]->setCountryCode(strtoupper($options['countrycode'])); $contacts[0]->save(); } else { $contactInformation = new QubitContactInformation(); $contactInformation->setCountryCode(strtoupper($options['countrycode'])); $contactInformation->setActorId($repository->id); $contactInformation->save(); } } } } } }