You are here

public function RangeFieldFormatterSettings::transform in Range 8

Get the range field formatter settings.

Overrides ProcessPluginBase::transform

File

src/Plugin/migrate/process/d6/RangeFieldFormatterSettings.php, line 24

Class

RangeFieldFormatterSettings
Get the range field formatter settings.

Namespace

Drupal\range\Plugin\migrate\process\d6

Code

public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
  list($module, $format) = $value;
  $type = $row
    ->getDestinationProperty('options/type');
  $map = [
    'range_decimal' => [
      'default' => [
        'field_prefix_suffix' => TRUE,
      ],
      'us_0' => [
        'scale' => 0,
        'decimal_separator' => '.',
        'thousand_separator' => ',',
        'field_prefix_suffix' => TRUE,
      ],
      'us_1' => [
        'scale' => 1,
        'decimal_separator' => '.',
        'thousand_separator' => ',',
        'field_prefix_suffix' => TRUE,
      ],
      'us_2' => [
        'scale' => 2,
        'decimal_separator' => '.',
        'thousand_separator' => ',',
        'field_prefix_suffix' => TRUE,
      ],
      'be_0' => [
        'scale' => 0,
        'decimal_separator' => ',',
        'thousand_separator' => '.',
        'field_prefix_suffix' => TRUE,
      ],
      'be_1' => [
        'scale' => 1,
        'decimal_separator' => ',',
        'thousand_separator' => '.',
        'field_prefix_suffix' => TRUE,
      ],
      'be_2' => [
        'scale' => 2,
        'decimal_separator' => ',',
        'thousand_separator' => '.',
        'field_prefix_suffix' => TRUE,
      ],
      'fr_0' => [
        'scale' => 0,
        'decimal_separator' => ',',
        'thousand_separator' => ' ',
        'field_prefix_suffix' => TRUE,
      ],
      'fr_1' => [
        'scale' => 1,
        'decimal_separator' => ',',
        'thousand_separator' => ' ',
        'field_prefix_suffix' => TRUE,
      ],
      'fr_2' => [
        'scale' => 2,
        'decimal_separator' => ',',
        'thousand_separator' => ' ',
        'field_prefix_suffix' => TRUE,
      ],
    ],
    'range_integer' => [
      'default' => [
        'field_prefix_suffix' => TRUE,
      ],
      'us_0' => [
        'thousand_separator' => ',',
        'field_prefix_suffix' => TRUE,
      ],
      'be_0' => [
        'thousand_separator' => '.',
        'field_prefix_suffix' => TRUE,
      ],
      'fr_0' => [
        'thousand_separator' => ' ',
        'field_prefix_suffix' => TRUE,
      ],
    ],
    'range_unformatted' => [
      'unformatted' => [
        'field_prefix_suffix' => TRUE,
      ],
    ],
  ];
  return $map[$type][$format] ?? [];
}