You are here

protected function XMLMigration::applyMappings in Migrate 7.2

Same name and namespace in other branches
  1. 6.2 plugins/sources/xml.inc \XMLMigration::applyMappings()

A normal $data_row has all the input data as top-level fields - in this case, however, the data is embedded within a SimpleXMLElement object in $data_row->xml. Explode that out to the normal form, and pass on to the normal implementation.

Overrides Migration::applyMappings

File

plugins/sources/xml.inc, line 368
Support for migration from XML sources.

Class

XMLMigration
Migrations using XML sources should extend this class instead of Migration.

Code

protected function applyMappings() {

  // We only know what data to pull from the xpaths in the mappings.
  foreach ($this
    ->getFieldMappings() as $mapping) {
    $source = $mapping
      ->getSourceField();
    if ($source && !isset($this->sourceValues->{$source})) {
      $xpath = $mapping
        ->getXpath();
      if ($xpath) {

        // Derived class may override applyXpath().
        $source_value = $this
          ->applyXpath($this->sourceValues, $xpath);
        if (!is_null($source_value)) {
          $this->sourceValues->{$source} = $source_value;
        }
      }
    }
  }
  parent::applyMappings();
}