You are here

function taxonomy_xml_merge_predicates_into_attributes in Taxonomy import/export via XML 7

Same name and namespace in other branches
  1. 5.2 taxonomy_xml.module \taxonomy_xml_merge_predicates_into_attributes()
  2. 5 taxonomy_xml.module \taxonomy_xml_merge_predicates_into_attributes()
  3. 6.2 taxonomy_xml.module \taxonomy_xml_merge_predicates_into_attributes()
  4. 6 taxonomy_xml.module \taxonomy_xml_merge_predicates_into_attributes()

Merge all predicate data into a simpler array.

Re-tags the attributes as needed

Parameters

An object containing a 'predicates' array. For each predicate, a: cannonically named attribute will be attached to the object.

1 call to taxonomy_xml_merge_predicates_into_attributes()
taxonomy_xml_absorb_vocabulary_definitions in ./taxonomy_xml.process.inc
Create Vocabulary definitions.

File

./taxonomy_xml.process.inc, line 663
The workhorse processes for importing taxonomies.

Code

function taxonomy_xml_merge_predicates_into_attributes(&$object) {
  if (empty($object)) {
    return;
  }
  $predicate_synonyms = taxonomy_xml_relationship_synonyms();

  // Diagnostics:
  if (empty($object->predicates)) {
    watchdog('taxonomy_xml', "When importing an object, I found some data with no predicates at all. This is odd, but probably no big deal. <pre>!object</pre>", array(
      '!object' => print_r($object, 1),
    ), WATCHDOG_NOTICE);
    $object->predicates = array();
  }
  foreach ($object->predicates as $predicate => $vals) {
    $predicate = isset($predicate_synonyms[$predicate]) ? $predicate_synonyms[$predicate] : $predicate;

    // If there are multiple and we need just one, make a guess.
    // Can't do much else.
    $object->{$predicate} = taxonomy_xml_get_literal_string($vals, $predicate);
  }
  if (empty($object->description) && isset($object->{TAXONOMY_XML_DESCRIPTION})) {
    $object->description = $object->{TAXONOMY_XML_DESCRIPTION};
  }
  return $object;
}