/** * Set defaults * * @param Concept $concept */ public function setDefaults($concept) { $vocabObj = $this->getCurrentVocabulary(); $vocabId = $vocabObj->getId(); $concept->setVocabularyId($vocabId); $conceptParam = $this->getContext()->getRequest()->getParameter('concept'); if (!$this->getContext()->getRequest()->getErrors() and !isset($conceptParam['uri'])) { $vocabDomain = $vocabObj->getBaseDomain(); $vocabToken = $vocabObj->getToken(); //get the next id $nextUriId = VocabularyPeer::getNextConceptId($vocabId); //URI looks like: agent(base_domain) / vocabulary(token) / vocabulary(next_concept_id) / skos_property_id # concept(next_property_id) $vSlash = preg_match('@(/$)@i', $vocabDomain) ? '' : '/'; $tSlash = preg_match('@(/$)@i', $vocabToken) ? '' : '/'; //to support hash URIs just a wee bit better... $tSlash = preg_match('/#$/', $vocabToken) ? '' : $tSlash; $newURI = $vocabDomain . $vSlash . $vocabToken . $tSlash . $nextUriId; //registry base domain is http://metadataregistry.org/uri/ //next_concept_id is always initialized to 100000, allowing for 999,999 concepts //vocabulary carries denormalized base_domain from agent $concept->setUri($newURI); $concept->setprefLabel(''); //set to the vocabulary defaults $concept->setLanguage($vocabObj->getLanguage()); $concept->setStatusId($vocabObj->getStatusId()); } parent::setDefaults($concept); }