Issue #2404955 by benjy: Field Formatter settings have incorrect mappings for number formats
parent
aff95777ed
commit
d3e7bdb18f
|
|
@ -57,9 +57,9 @@ process:
|
|||
plain: basic_string
|
||||
number_integer:
|
||||
default: number_integer
|
||||
us_3: number_integer
|
||||
be_3: number_integer
|
||||
fr_3: number_integer
|
||||
us_0: number_integer
|
||||
be_0: number_integer
|
||||
fr_0: number_integer
|
||||
unformatted: number_unformatted
|
||||
number_float:
|
||||
default: number_decimal
|
||||
|
|
@ -180,61 +180,6 @@ process:
|
|||
- module
|
||||
- 'display_settings/format'
|
||||
map:
|
||||
number:
|
||||
us_0:
|
||||
scale: 0
|
||||
decimal_separator: .
|
||||
thousand_separator: ','
|
||||
prefix_suffix: true
|
||||
us_1:
|
||||
scale: 1
|
||||
decimal_separator: .
|
||||
thousand_separator: ','
|
||||
prefix_suffix: true
|
||||
us_2:
|
||||
scale: 2
|
||||
decimal_separator: .
|
||||
thousand_separator: ','
|
||||
prefix_suffix: true
|
||||
us_3:
|
||||
thousand_separator: ','
|
||||
prefix_suffix: true
|
||||
be_0:
|
||||
scale: 0
|
||||
decimal_separator: ','
|
||||
thousand_separator: .
|
||||
prefix_suffix: true
|
||||
be_1:
|
||||
scale: 1
|
||||
decimal_separator: ','
|
||||
thousand_separator: .
|
||||
prefix_suffix: true
|
||||
be_2:
|
||||
scale: 2
|
||||
decimal_separator: ','
|
||||
thousand_separator: .
|
||||
prefix_suffix: true
|
||||
be_3:
|
||||
thousand_separator: .
|
||||
prefix_suffix: true
|
||||
fr_0:
|
||||
scale: 0
|
||||
decimal_separator: ','
|
||||
thousand_separator: ' '
|
||||
prefix_suffix: true
|
||||
fr_1:
|
||||
scale: 1
|
||||
decimal_separator: ','
|
||||
thousand_separator: ' '
|
||||
prefix_suffix: true
|
||||
fr_2:
|
||||
scale: 2
|
||||
decimal_separator: ','
|
||||
thousand_separator: ' '
|
||||
prefix_suffix: true
|
||||
fr_3:
|
||||
thousand_separator: ' '
|
||||
prefix_suffix: true
|
||||
link:
|
||||
default:
|
||||
trim_length: '80'
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\process\d6;
|
||||
|
||||
use Drupal\migrate\MigrateException;
|
||||
use Drupal\migrate\ProcessPluginBase;
|
||||
use Drupal\migrate\MigrateExecutable;
|
||||
use Drupal\migrate\Row;
|
||||
|
|
@ -29,9 +30,109 @@ class FieldFormatterSettingsDefaults extends ProcessPluginBase {
|
|||
public function transform($value, MigrateExecutable $migrate_executable, Row $row, $destination_property) {
|
||||
// If the 1 index is set then the map missed.
|
||||
if (isset($value[1])) {
|
||||
$value = $row->getSourceProperty('module') == 'date' ? array('format_type' => 'fallback') : array();
|
||||
$module = $row->getSourceProperty('module');
|
||||
if ($module === 'date') {
|
||||
$value = array('format_type' => 'fallback');
|
||||
}
|
||||
elseif ($module === 'number') {
|
||||
// We have to do the lookup here in the process plugin because for
|
||||
// number we need to calculated the settings based on the type not just
|
||||
// the module which works well for other field types.
|
||||
return $this->numberSettings($row->getDestinationProperty('options/type'), $value[1]);
|
||||
}
|
||||
else {
|
||||
$value = array();
|
||||
}
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $type
|
||||
* The field type.
|
||||
* @param $format
|
||||
* The format selected for the field on the display.
|
||||
*
|
||||
* @return array
|
||||
* The correct default settings.
|
||||
*
|
||||
* @throws \Drupal\migrate\MigrateException
|
||||
*/
|
||||
protected function numberSettings($type, $format) {
|
||||
$map = [
|
||||
'number_decimal' => [
|
||||
'us_0' => [
|
||||
'scale' => 0,
|
||||
'decimal_separator' => '.',
|
||||
'thousand_separator' => ',',
|
||||
'prefix_suffix' => TRUE,
|
||||
],
|
||||
'us_1' => [
|
||||
'scale' => 1,
|
||||
'decimal_separator' => '.',
|
||||
'thousand_separator' => ',',
|
||||
'prefix_suffix' => TRUE,
|
||||
],
|
||||
'us_2' => [
|
||||
'scale' => 2,
|
||||
'decimal_separator' => '.',
|
||||
'thousand_separator' => ',',
|
||||
'prefix_suffix' => TRUE,
|
||||
],
|
||||
'be_0' => [
|
||||
'scale' => 0,
|
||||
'decimal_separator' => ',',
|
||||
'thousand_separator' => '.',
|
||||
'prefix_suffix' => TRUE,
|
||||
],
|
||||
'be_1' => [
|
||||
'scale' => 1,
|
||||
'decimal_separator' => ',',
|
||||
'thousand_separator' => '.',
|
||||
'prefix_suffix' => TRUE,
|
||||
],
|
||||
'be_2' => [
|
||||
'scale' => 2,
|
||||
'decimal_separator' => ',',
|
||||
'thousand_separator' => '.',
|
||||
'prefix_suffix' => TRUE,
|
||||
],
|
||||
'fr_0' => [
|
||||
'scale' => 0,
|
||||
'decimal_separator' => ',',
|
||||
'thousand_separator' => ' ',
|
||||
'prefix_suffix' => TRUE,
|
||||
],
|
||||
'fr_1' => [
|
||||
'scale' => 1,
|
||||
'decimal_separator' => ',',
|
||||
'thousand_separator' => ' ',
|
||||
'prefix_suffix' => TRUE,
|
||||
],
|
||||
'fr_2' => [
|
||||
'scale' => 2,
|
||||
'decimal_separator' => ',',
|
||||
'thousand_separator' => ' ',
|
||||
'prefix_suffix' => TRUE,
|
||||
],
|
||||
],
|
||||
'number_integer' => [
|
||||
'us_0' => [
|
||||
'thousand_separator' => ',',
|
||||
'prefix_suffix' => TRUE,
|
||||
],
|
||||
'be_0' => [
|
||||
'thousand_separator' => '.',
|
||||
'prefix_suffix' => TRUE,
|
||||
],
|
||||
'fr_0' => [
|
||||
'thousand_separator' => ' ',
|
||||
'prefix_suffix' => TRUE,
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
return isset($map[$type][$format]) ? $map[$type][$format] : [];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -193,11 +193,11 @@ class Drupal6FieldInstance extends Drupal6DumpBase {
|
|||
'format' => 'above',
|
||||
),
|
||||
'teaser' => array(
|
||||
'format' => 'unformatted',
|
||||
'format' => 'us_0',
|
||||
'exclude' => 0,
|
||||
),
|
||||
'full' => array(
|
||||
'format' => 'us_3',
|
||||
'format' => 'us_0',
|
||||
'exclude' => 0,
|
||||
),
|
||||
4 => array(
|
||||
|
|
@ -708,7 +708,7 @@ class Drupal6FieldInstance extends Drupal6DumpBase {
|
|||
'exclude' => 0,
|
||||
),
|
||||
'full' => array(
|
||||
'format' => 'us_3',
|
||||
'format' => 'us_0',
|
||||
'exclude' => 0,
|
||||
),
|
||||
4 => array(
|
||||
|
|
@ -808,7 +808,7 @@ class Drupal6FieldInstance extends Drupal6DumpBase {
|
|||
'exclude' => 0,
|
||||
),
|
||||
'full' => array(
|
||||
'format' => 'us_3',
|
||||
'format' => 'us_0',
|
||||
'exclude' => 0,
|
||||
),
|
||||
4 => array(
|
||||
|
|
@ -840,7 +840,7 @@ class Drupal6FieldInstance extends Drupal6DumpBase {
|
|||
'exclude' => 0,
|
||||
),
|
||||
'full' => array(
|
||||
'format' => 'us_3',
|
||||
'format' => 'us_0',
|
||||
'exclude' => 0,
|
||||
),
|
||||
4 => array(
|
||||
|
|
|
|||
Loading…
Reference in New Issue