You are here

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

Generate default format mappings based on matching names. E.g., if the Drupal 6 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

d6/d6.inc, line 24
Implementation of DrupalVersion for Drupal 6 sources.

Class

DrupalVersion6
Drupal 6 implementations of functions shared among multiple types of objects.

Code

public function getDefaultFormatMappings() {
  migrate_instrument_start('DrupalVersion6::getDefaultFormatMappings');
  $format_mappings = array();
  $d6_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($d6_formats), 'IN')
    ->execute()
    ->fetchAllKeyed();
  foreach ($d6_formats as $name => $format) {
    if (isset($d7_formats[$name])) {
      $format_mappings[$format] = $d7_formats[$name];
    }
  }
  migrate_instrument_stop('DrupalVersion6::getDefaultFormatMappings');
  return $format_mappings;
}