public function DrupalVersion7::getDefaultFormatMappings in Drupal-to-Drupal data migration 7.2
Generate default format mappings based on matching machine names or display names.
Overrides DrupalVersion::getDefaultFormatMappings
File
- d7/
d7.inc, line 12 - Implementation of DrupalVersion for Drupal 7 sources.
Class
- DrupalVersion7
- @file Implementation of DrupalVersion for Drupal 7 sources.
Code
public function getDefaultFormatMappings() {
$format_mappings = array();
$formats = filter_formats();
$result = Database::getConnection('default', $this->arguments['source_connection'])
->select('filter_format', 'f')
->fields('f', array(
'format',
'name',
))
->execute();
foreach ($result as $format_row) {
// Take a match on the machine name.
if (isset($formats[$format_row->format])) {
$format_mappings[$format_row->format] = $format_row->format;
}
else {
// Otherwise, look for a matching display name.
foreach ($formats as $machine_name => $format_info) {
if (drupal_strtolower($format_row->name) == drupal_strtolower($format_info->name)) {
$format_mappings[$format_row->format] = $machine_name;
break;
}
}
}
}
return $format_mappings;
}