You are here

public function DrupalVersion5::getDefaultFormatMappings in Drupal-to-Drupal data migration 7.2

Generate default format mappings based on matching names. E.g., if the Drupal 5 database has format 5 with name 'Filtered HTML', and the Drupal 7 databas has format filtered_html with name 'Filtered HTML', the resulting array will contain the row '5' => 'filtered_html'.

Overrides DrupalVersion::getDefaultFormatMappings

File

d5/d5.inc, line 24
Implementation of DrupalVersion for Drupal 5 sources.

Class

DrupalVersion5
Drupal 5 implementations of functions shared among multiple types of objects.

Code

public function getDefaultFormatMappings() {
  migrate_instrument_start('DrupalVersion5::getDefaultFormatMappings');
  $format_mappings = array();
  $d5_formats = Database::getConnection('default', $this->arguments['source_connection'])
    ->select('filter_formats', 'f')
    ->fields('f', array(
    'name',
    'format',
  ))
    ->execute()
    ->fetchAllKeyed();
  $d7_formats = db_select('filter_format', 'f')
    ->fields('f', array(
    'name',
    'format',
  ))
    ->condition('name', array_keys($d5_formats), 'IN')
    ->execute()
    ->fetchAllKeyed();
  foreach ($d5_formats as $name => $format) {
    if (isset($d7_formats[$name])) {
      $format_mappings[$format] = $d7_formats[$name];
    }
  }
  migrate_instrument_stop('DrupalVersion5::getDefaultFormatMappings');
  return $format_mappings;
}