/** * Import data from an parsed ODD xml data array. * * @param ODD $data XML data * * @return true * * @throws InvalidParameterException * @deprecated 1.9 Use toObject() */ public function import(ODD $data) { elgg_deprecated_notice(__METHOD__ . ' has been deprecated', 1.9); if (!$data instanceof ODDEntity) { throw new \InvalidParameterException("import() passed an unexpected ODD class"); } // Set type and subtype $this->attributes['type'] = $data->getAttribute('class'); $this->attributes['subtype'] = $data->getAttribute('subclass'); // Set owner $this->attributes['owner_guid'] = _elgg_services()->session->getLoggedInUserGuid(); // Import as belonging to importer. // Set time $this->attributes['time_created'] = strtotime($data->getAttribute('published')); $this->attributes['time_updated'] = time(); return true; }
/** * Import a relationship * * @param ODD $data ODD data * @return bool * @throws ImportException */ public function import(ODD $data) { if (!$data instanceof ODDRelationship) { throw new InvalidParameterException(elgg_echo('InvalidParameterException:UnexpectedODDClass')); } $uuid_one = $data->getAttribute('uuid1'); $uuid_two = $data->getAttribute('uuid2'); // See if this entity has already been imported, if so then we need to link to it $entity1 = get_entity_from_uuid($uuid_one); $entity2 = get_entity_from_uuid($uuid_two); if ($entity1 && $entity2) { // Set the item ID $this->attributes['guid_one'] = $entity1->getGUID(); $this->attributes['guid_two'] = $entity2->getGUID(); // Map verb to relationship //$verb = $data->getAttribute('verb'); //$relationship = get_relationship_from_verb($verb); $relationship = $data->getAttribute('type'); if ($relationship) { $this->attributes['relationship'] = $relationship; // save $result = $this->save(); if (!$result) { throw new ImportException(elgg_echo('ImportException:ProblemSaving', array(get_class()))); } return true; } } }
/** * Import data from an parsed ODD xml data array. * * @param array $data XML data * * @return true */ public function import(ODD $data) { if (!$data instanceof ODDEntity) { throw new InvalidParameterException(elgg_echo('InvalidParameterException:UnexpectedODDClass')); } // Set type and subtype $this->attributes['type'] = $data->getAttribute('class'); $this->attributes['subtype'] = $data->getAttribute('subclass'); // Set owner $this->attributes['owner_guid'] = elgg_get_logged_in_user_guid(); // Import as belonging to importer. // Set time $this->attributes['time_created'] = strtotime($data->getAttribute('published')); $this->attributes['time_updated'] = time(); return true; }
/** * Import a relationship * * @param ODD $data ODD data * @return bool * @throws ImportException|InvalidParameterException * @deprecated 1.9 */ public function import(ODD $data) { elgg_deprecated_notice(__METHOD__ . ' has been deprecated', 1.9); if (!$data instanceof ODDRelationship) { throw new \InvalidParameterException("import() passed an unexpected ODD class"); } $uuid_one = $data->getAttribute('uuid1'); $uuid_two = $data->getAttribute('uuid2'); // See if this entity has already been imported, if so then we need to link to it $entity1 = get_entity_from_uuid($uuid_one); $entity2 = get_entity_from_uuid($uuid_two); if ($entity1 && $entity2) { // Set the item ID $this->attributes['guid_one'] = $entity1->getGUID(); $this->attributes['guid_two'] = $entity2->getGUID(); // Map verb to relationship //$verb = $data->getAttribute('verb'); //$relationship = get_relationship_from_verb($verb); $relationship = $data->getAttribute('type'); if ($relationship) { $this->attributes['relationship'] = $relationship; // save $result = $this->save(); if (!$result) { throw new \ImportException("There was a problem saving " . get_class()); } return true; } } return false; }