protected function addTermRelations($concept) { $subjectUri = $concept->getAttributeNodeNS('http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'about'); if (!$subjectUri instanceof DOMAttr || !isset($this->terms[$subjectUri->nodeValue])) { continue; } foreach ($this->xpath->query('./skos:related', $concept) as $related) { $objectUri = $related->getAttributeNodeNS('http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'resource'); if (!$objectUri instanceof DomAttr || !isset($this->terms[$objectUri->nodeValue])) { continue; } // Don't duplicate relationship foreach ($this->relations as $r) { if ($r['subject'] == $objectUri->nodeValue && $r['object'] == $subjectUri->nodeValue || $r['subject'] == $subjectUri->nodeValue && $r['object'] == $objectUri->nodeValue) { continue 2; } } $relation = new QubitRelation(); $relation->typeId = QubitTerm::TERM_RELATION_ASSOCIATIVE_ID; $relation->subject = $this->terms[$subjectUri->nodeValue]; $relation->object = $this->terms[$objectUri->nodeValue]; $relation->save(); $this->relations[] = array('subject' => $subjectUri->nodeValue, 'object' => $objectUri->nodeValue); } return $this; }