Commit 57a78f13 authored by KarenS's avatar KarenS
Browse files

#1039466 by yched, Don't clobber formatter settings provided by third party modules.

parent 70de9852
...@@ -44,26 +44,24 @@ function content_migrate_number_field_alter(&$field_value, $instance_value) { ...@@ -44,26 +44,24 @@ function content_migrate_number_field_alter(&$field_value, $instance_value) {
case 'optionwidgets_onoff': case 'optionwidgets_onoff':
$field_value['type'] = 'list_boolean'; $field_value['type'] = 'list_boolean';
$field_value['module'] = 'list'; $field_value['module'] = 'list';
break; break;
} }
break; break;
} }
} }
/** /**
* Implements hook_content_migrate_instance_alter(). * Implements hook_content_migrate_instance_alter().
* *
* Use this to tweak the conversion of instance or widget settings * Use this to tweak the conversion of instance or widget settings
* from the D6 style to the D7 style for specific * from the D6 style to the D7 style for specific
* situations not handled by basic conversion, as when * situations not handled by basic conversion, as when
* formatter or widget names or settings are changed. * formatter or widget names or settings are changed.
*/ */
function content_migrate_number_instance_alter(&$instance_value, $field_value) { function content_migrate_number_instance_alter(&$instance_value, $field_value) {
switch ($field_value['module']) {
// Switch case 'number':
switch ($instance_value['widget']['module']) {
case 'number':
// The number formatters and formatter settings // The number formatters and formatter settings
// have changed. // have changed.
$new_type = array( $new_type = array(
...@@ -139,13 +137,15 @@ function content_migrate_number_instance_alter(&$instance_value, $field_value) { ...@@ -139,13 +137,15 @@ function content_migrate_number_instance_alter(&$instance_value, $field_value) {
'decimal_separator' => ', ', 'decimal_separator' => ', ',
'scale' => 2, 'scale' => 2,
'prefix_suffix' => TRUE, 'prefix_suffix' => TRUE,
), ),
); );
foreach ($instance_value['display'] as $context => $settings) { foreach ($instance_value['display'] as $context => $settings) {
$instance_value['display'][$context]['type'] = $new_type[$settings['type']]; if ($settings['module'] == 'number') {
$instance_value['display'][$context]['settings'] = $new_settings[$settings['type']]; $instance_value['display'][$context]['type'] = $new_type[$settings['type']];
$instance_value['display'][$context]['settings'] = $new_settings[$settings['type']];
}
} }
break; break;
} }
} }
...@@ -69,23 +69,23 @@ function content_migrate_text_field_alter(&$field_value, $instance_value) { ...@@ -69,23 +69,23 @@ function content_migrate_text_field_alter(&$field_value, $instance_value) {
/** /**
* Implements hook_content_migrate_instance_alter(). * Implements hook_content_migrate_instance_alter().
* *
* Use this to tweak the conversion of instance or widget settings * Use this to tweak the conversion of instance or widget settings
* from the D6 style to the D7 style for specific * from the D6 style to the D7 style for specific
* situations not handled by basic conversion, as when * situations not handled by basic conversion, as when
* formatter or widget names or settings are changed. * formatter or widget names or settings are changed.
*/ */
function content_migrate_text_instance_alter(&$instance_value, $field_value) { function content_migrate_text_instance_alter(&$instance_value, $field_value) {
switch ($field_value['module']) {
// Switch
switch ($instance_value['widget']['module']) {
case 'text': case 'text':
// The formatter names changed, all are prefixed // The formatter names changed, all are prefixed
// with 'text_'. // with 'text_'.
foreach ($instance_value['display'] as $context => $settings) { foreach ($instance_value['display'] as $context => $settings) {
$instance_value['display'][$context]['type'] = 'text_'. $settings['type']; if ($settings['module'] == 'text') {
} $instance_value['display'][$context]['type'] = 'text_'. $settings['type'];
}
}
break; break;
} }
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment