/** * Attempt to construct an ODD object out of a XmlElement or sub-elements. * * @param XmlElement $element The element(s) * * @return mixed An ODD object if the element can be handled, or false. */ function ODD_factory(XmlElement $element) { $name = $element->name; $odd = false; switch ($name) { case 'entity': $odd = new ODDEntity("", "", ""); break; case 'metadata': $odd = new ODDMetaData("", "", "", ""); break; case 'relationship': $odd = new ODDRelationship("", "", ""); break; } // Now populate values if ($odd) { // Attributes foreach ($element->attributes as $k => $v) { $odd->setAttribute($k, $v); } // Body $body = $element->content; $a = stripos($body, "<![CDATA"); $b = strripos($body, "]]>"); if ($body && $a !== false && $b !== false) { $body = substr($body, $a + 8, $b - ($a + 8)); } $odd->setBody($body); } return $odd; }
/** * Export this relationship * * @return array */ public function export() { $uuid = get_uuid_from_object($this); $relationship = new ODDRelationship(guid_to_uuid($this->guid_one), $this->relationship, guid_to_uuid($this->guid_two)); $relationship->setAttribute('uuid', $uuid); return $relationship; }
/** * Export this relationship * * @return array * @deprecated 1.9 Use toObject() */ public function export() { elgg_deprecated_notice(__METHOD__ . ' has been deprecated', 1.9); $uuid = get_uuid_from_object($this); $relationship = new ODDRelationship(guid_to_uuid($this->guid_one), $this->relationship, guid_to_uuid($this->guid_two)); $relationship->setAttribute('uuid', $uuid); return $relationship; }