You are here

function taxonomy_xml_merge_predicates_into_attributes in Taxonomy import/export via XML 6.2

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 taxonomy_xml.module \taxonomy_xml_merge_predicates_into_attributes()
  4. 7 taxonomy_xml.process.inc \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.module
Create Vocabulary definitions.

File

./taxonomy_xml.module, line 1200
This module makes it possible to import and export taxonomies as XML documents.

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;
    $object->{$predicate} = array_pop($vals);
  }
  if (empty($object->description) && isset($object->{TAXONOMY_XML_DESCRIPTION})) {
    $object->description = $object->{TAXONOMY_XML_DESCRIPTION};
  }
  return $object;
}