You are here

protected function FieldFormatterSettingsDefaults::numberSettings in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/field/src/Plugin/migrate/process/d6/FieldFormatterSettingsDefaults.php \Drupal\field\Plugin\migrate\process\d6\FieldFormatterSettingsDefaults::numberSettings()

Parameters

string $type: The field type.

$format: The format selected for the field on the display.

Return value

array The correct default settings.

Throws

\Drupal\migrate\MigrateException

1 call to FieldFormatterSettingsDefaults::numberSettings()
FieldFormatterSettingsDefaults::transform in core/modules/field/src/Plugin/migrate/process/d6/FieldFormatterSettingsDefaults.php
Set field formatter settings when the map didn't map: for date formatters, the fallback format, for everything else, empty array.

File

core/modules/field/src/Plugin/migrate/process/d6/FieldFormatterSettingsDefaults.php, line 55

Class

FieldFormatterSettingsDefaults
Set the default field settings.

Namespace

Drupal\field\Plugin\migrate\process\d6

Code

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] : [];
}