Issue #3008029 by quietone, Gábor Hojtsy: Migrate D7 i18n field option translations
							parent
							
								
									df123b1c2d
								
							
						
					
					
						commit
						b4192ba2eb
					
				| 
						 | 
				
			
			@ -0,0 +1,57 @@
 | 
			
		|||
id: d7_field_instance_option_translation
 | 
			
		||||
label: Field instance option configuration translation
 | 
			
		||||
migration_tags:
 | 
			
		||||
  - Drupal 7
 | 
			
		||||
  - Configuration
 | 
			
		||||
  - Multilingual
 | 
			
		||||
source:
 | 
			
		||||
  plugin: d7_field_option_translation
 | 
			
		||||
  constants:
 | 
			
		||||
    status: true
 | 
			
		||||
process:
 | 
			
		||||
  langcode:
 | 
			
		||||
    plugin: skip_on_empty
 | 
			
		||||
    source: language
 | 
			
		||||
    method: row
 | 
			
		||||
  type:
 | 
			
		||||
    plugin: process_field
 | 
			
		||||
    source: type
 | 
			
		||||
    method: getFieldType
 | 
			
		||||
  entity_type: entity_type
 | 
			
		||||
  field_name: field_name
 | 
			
		||||
#  # The bundle needs to be statically mapped in order to support comment types
 | 
			
		||||
#  # that might already exist before this migration is run. See
 | 
			
		||||
#  # d7_comment_type.yml for more information.
 | 
			
		||||
  bundle:
 | 
			
		||||
    plugin: static_map
 | 
			
		||||
    source: bundle
 | 
			
		||||
    bypass: true
 | 
			
		||||
    map:
 | 
			
		||||
      comment_node_forum: comment_forum
 | 
			
		||||
  results:
 | 
			
		||||
    plugin: d7_field_instance_option_translation
 | 
			
		||||
    source:
 | 
			
		||||
      - '@type'
 | 
			
		||||
      - data
 | 
			
		||||
  translation:
 | 
			
		||||
    -
 | 
			
		||||
      plugin: extract
 | 
			
		||||
      source: '@results'
 | 
			
		||||
      index: [1]
 | 
			
		||||
    -
 | 
			
		||||
      plugin: skip_on_empty
 | 
			
		||||
      method: row
 | 
			
		||||
  property:
 | 
			
		||||
    -
 | 
			
		||||
      plugin: extract
 | 
			
		||||
      source: '@results'
 | 
			
		||||
      index: [0]
 | 
			
		||||
    -
 | 
			
		||||
      plugin: skip_on_empty
 | 
			
		||||
      method: row
 | 
			
		||||
destination:
 | 
			
		||||
  plugin: entity:field_config
 | 
			
		||||
  translations: true
 | 
			
		||||
migration_dependencies:
 | 
			
		||||
  required:
 | 
			
		||||
    - d7_field_instance
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,47 @@
 | 
			
		|||
id: d7_field_option_translation
 | 
			
		||||
label: Field option configuration translation
 | 
			
		||||
migration_tags:
 | 
			
		||||
  - Drupal 7
 | 
			
		||||
  - Configuration
 | 
			
		||||
  - Multilingual
 | 
			
		||||
field_plugin_method: alterFieldMigration
 | 
			
		||||
source:
 | 
			
		||||
  plugin: d7_field_option_translation
 | 
			
		||||
process:
 | 
			
		||||
  langcode:
 | 
			
		||||
    plugin: skip_on_empty
 | 
			
		||||
    source: language
 | 
			
		||||
    method: row
 | 
			
		||||
  entity_type: entity_type
 | 
			
		||||
  field_name: field_name
 | 
			
		||||
  type:
 | 
			
		||||
    plugin: process_field
 | 
			
		||||
    source: type
 | 
			
		||||
    method: getFieldType
 | 
			
		||||
  results:
 | 
			
		||||
    plugin: d7_field_option_translation
 | 
			
		||||
    source:
 | 
			
		||||
      - '@type'
 | 
			
		||||
      - data
 | 
			
		||||
  translation:
 | 
			
		||||
    -
 | 
			
		||||
      plugin: extract
 | 
			
		||||
      source: '@results'
 | 
			
		||||
      index: [1]
 | 
			
		||||
    -
 | 
			
		||||
      plugin: skip_on_empty
 | 
			
		||||
      method: row
 | 
			
		||||
  property:
 | 
			
		||||
    -
 | 
			
		||||
      plugin: extract
 | 
			
		||||
      source: '@results'
 | 
			
		||||
      index: [0]
 | 
			
		||||
    -
 | 
			
		||||
      plugin: skip_on_empty
 | 
			
		||||
      method: row
 | 
			
		||||
destination:
 | 
			
		||||
  plugin: entity:field_storage_config
 | 
			
		||||
  translations: true
 | 
			
		||||
migration_dependencies:
 | 
			
		||||
  required:
 | 
			
		||||
    - d7_field
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,45 @@
 | 
			
		|||
<?php
 | 
			
		||||
 | 
			
		||||
namespace Drupal\field\Plugin\migrate\process\d7;
 | 
			
		||||
 | 
			
		||||
use Drupal\migrate\MigrateExecutableInterface;
 | 
			
		||||
use Drupal\migrate\ProcessPluginBase;
 | 
			
		||||
use Drupal\migrate\Row;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Determines the settings property and translation for boolean fields.
 | 
			
		||||
 *
 | 
			
		||||
 * @MigrateProcessPlugin(
 | 
			
		||||
 *   id = "d7_field_instance_option_translation",
 | 
			
		||||
 *   handle_multiples = TRUE
 | 
			
		||||
 * )
 | 
			
		||||
 */
 | 
			
		||||
class FieldInstanceOptionTranslation extends ProcessPluginBase {
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * {@inheritdoc}
 | 
			
		||||
   */
 | 
			
		||||
  public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
 | 
			
		||||
    list($type, $data) = $value;
 | 
			
		||||
 | 
			
		||||
    $data = unserialize($data);
 | 
			
		||||
    $property = $row->getSourceProperty('property');
 | 
			
		||||
    $option_key = ($property == 0) ? 'off_label' : 'on_label';
 | 
			
		||||
    $translation = '';
 | 
			
		||||
    if (isset($data['settings']['allowed_values'])) {
 | 
			
		||||
      $allowed_values = $data['settings']['allowed_values'];
 | 
			
		||||
      switch ($type) {
 | 
			
		||||
        case 'boolean';
 | 
			
		||||
          if (isset($allowed_values[$property])) {
 | 
			
		||||
            $translation = $row->getSourceProperty('translation');
 | 
			
		||||
            break;
 | 
			
		||||
          }
 | 
			
		||||
          break;
 | 
			
		||||
 | 
			
		||||
        default:
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    return ['settings.' . $option_key, $translation];
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,50 @@
 | 
			
		|||
<?php
 | 
			
		||||
 | 
			
		||||
namespace Drupal\field\Plugin\migrate\process\d7;
 | 
			
		||||
 | 
			
		||||
use Drupal\migrate\MigrateExecutableInterface;
 | 
			
		||||
use Drupal\migrate\ProcessPluginBase;
 | 
			
		||||
use Drupal\migrate\Row;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Determines the allowed values translation for select lists.
 | 
			
		||||
 *
 | 
			
		||||
 * @MigrateProcessPlugin(
 | 
			
		||||
 *   id = "d7_field_option_translation",
 | 
			
		||||
 *   handle_multiples = TRUE
 | 
			
		||||
 * )
 | 
			
		||||
 */
 | 
			
		||||
class FieldOptionTranslation extends ProcessPluginBase {
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * {@inheritdoc}
 | 
			
		||||
   *
 | 
			
		||||
   * Get the field default/mapped settings.
 | 
			
		||||
   */
 | 
			
		||||
  public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
 | 
			
		||||
    list($type, $data) = $value;
 | 
			
		||||
 | 
			
		||||
    $data = unserialize($data);
 | 
			
		||||
    $allowed_values = '';
 | 
			
		||||
    $translation_key = $row->getSourceProperty('property');
 | 
			
		||||
    $i = 0;
 | 
			
		||||
    if (isset($data['settings']['allowed_values'])) {
 | 
			
		||||
      $allowed_values = $data['settings']['allowed_values'];
 | 
			
		||||
      switch ($type) {
 | 
			
		||||
        case 'list_string':
 | 
			
		||||
        case 'list_integer':
 | 
			
		||||
        case 'list_float':
 | 
			
		||||
        case 'list_text':
 | 
			
		||||
          if (isset($allowed_values[$translation_key])) {
 | 
			
		||||
            $allowed_values = ['label' => $row->getSourceProperty('translation')];
 | 
			
		||||
            break;
 | 
			
		||||
          }
 | 
			
		||||
          break;
 | 
			
		||||
 | 
			
		||||
        default:
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    return ["settings.allowed_values.$translation_key", $allowed_values];
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,70 @@
 | 
			
		|||
<?php
 | 
			
		||||
 | 
			
		||||
namespace Drupal\field\Plugin\migrate\source\d7;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Gets field option label translations.
 | 
			
		||||
 *
 | 
			
		||||
 * @MigrateSource(
 | 
			
		||||
 *   id = "d7_field_option_translation",
 | 
			
		||||
 *   source_module = "i18n_field"
 | 
			
		||||
 * )
 | 
			
		||||
 */
 | 
			
		||||
class FieldOptionTranslation extends Field {
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * {@inheritdoc}
 | 
			
		||||
   */
 | 
			
		||||
  public function query() {
 | 
			
		||||
    $query = parent::query();
 | 
			
		||||
    $query->leftJoin('i18n_string', 'i18n', 'i18n.type = fc.field_name');
 | 
			
		||||
    $query->leftJoin('locales_target', 'lt', 'lt.lid = i18n.lid');
 | 
			
		||||
    $query->condition('i18n.textgroup', 'field')
 | 
			
		||||
      ->condition('objectid', '#allowed_values')
 | 
			
		||||
      ->isNotNull('language');
 | 
			
		||||
    // Add all i18n and locales_target fields.
 | 
			
		||||
    $query
 | 
			
		||||
      ->fields('i18n')
 | 
			
		||||
      ->fields('lt');
 | 
			
		||||
    $query->addField('fc', 'type');
 | 
			
		||||
    $query->addField('fci', 'bundle');
 | 
			
		||||
    $query->addField('i18n', 'lid', 'i18n_lid');
 | 
			
		||||
    $query->addField('i18n', 'type', 'i18n_type');
 | 
			
		||||
 | 
			
		||||
    return $query;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * {@inheritdoc}
 | 
			
		||||
   */
 | 
			
		||||
  public function fields() {
 | 
			
		||||
    $fields = [
 | 
			
		||||
      'bundle' => $this->t('Entity bundle'),
 | 
			
		||||
      'lid' => $this->t('Source string ID'),
 | 
			
		||||
      'textgroup' => $this->t('A module defined group of translations'),
 | 
			
		||||
      'context' => $this->t('Full string ID'),
 | 
			
		||||
      'objectid' => $this->t('Object ID'),
 | 
			
		||||
      'property' => $this->t('Object property for this string'),
 | 
			
		||||
      'objectindex' => $this->t('Integer value of Object ID'),
 | 
			
		||||
      'format' => $this->t('The input format used by this string'),
 | 
			
		||||
      'translation' => $this->t('Translation of the option'),
 | 
			
		||||
      'language' => $this->t('Language code'),
 | 
			
		||||
      'plid' => $this->t('Parent lid'),
 | 
			
		||||
      'plural' => $this->t('Plural index number in case of plural strings'),
 | 
			
		||||
      'i18n_status' => $this->t('A boolean indicating whether this translation needs to be updated'),
 | 
			
		||||
    ];
 | 
			
		||||
    return parent::fields() + $fields;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * {@inheritdoc}
 | 
			
		||||
   */
 | 
			
		||||
  public function getIds() {
 | 
			
		||||
    return parent::getIds() +
 | 
			
		||||
      [
 | 
			
		||||
        'language' => ['type' => 'string'],
 | 
			
		||||
        'property' => ['type' => 'string'],
 | 
			
		||||
      ];
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,110 @@
 | 
			
		|||
<?php
 | 
			
		||||
 | 
			
		||||
namespace Drupal\Tests\field\Kernel\Migrate\d7;
 | 
			
		||||
 | 
			
		||||
use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Migrate field option translations.
 | 
			
		||||
 *
 | 
			
		||||
 * @group migrate_drupal_7
 | 
			
		||||
 */
 | 
			
		||||
class MigrateFieldOptionTranslationTest extends MigrateDrupal7TestBase {
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * {@inheritdoc}
 | 
			
		||||
   */
 | 
			
		||||
  public static $modules = [
 | 
			
		||||
    'comment',
 | 
			
		||||
    'config_translation',
 | 
			
		||||
    'datetime',
 | 
			
		||||
    'file',
 | 
			
		||||
    'image',
 | 
			
		||||
    'language',
 | 
			
		||||
    'link',
 | 
			
		||||
    'locale',
 | 
			
		||||
    'menu_ui',
 | 
			
		||||
    'node',
 | 
			
		||||
    'system',
 | 
			
		||||
    'taxonomy',
 | 
			
		||||
    'telephone',
 | 
			
		||||
    'text',
 | 
			
		||||
  ];
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * {@inheritdoc}
 | 
			
		||||
   */
 | 
			
		||||
  protected function setUp() {
 | 
			
		||||
    parent::setUp();
 | 
			
		||||
    $this->executeMigrations([
 | 
			
		||||
      'language',
 | 
			
		||||
      'd7_field',
 | 
			
		||||
      'd7_field_option_translation',
 | 
			
		||||
    ]);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Tests the Drupal 7 field option translation to Drupal 8 migration.
 | 
			
		||||
   */
 | 
			
		||||
  public function testFieldOptionTranslation() {
 | 
			
		||||
    $language_manager = $this->container->get('language_manager');
 | 
			
		||||
 | 
			
		||||
    /** @var \Drupal\language\Config\LanguageConfigOverride $config_translation */
 | 
			
		||||
    $config_translation = $language_manager->getLanguageConfigOverride('fr', 'field.storage.node.field_color');
 | 
			
		||||
    $allowed_values = [
 | 
			
		||||
      0 => [
 | 
			
		||||
        'label' => 'Verte',
 | 
			
		||||
      ],
 | 
			
		||||
      1 => [
 | 
			
		||||
        'label' => 'Noire',
 | 
			
		||||
      ],
 | 
			
		||||
      2 => [
 | 
			
		||||
        'label' => 'Blanche',
 | 
			
		||||
      ],
 | 
			
		||||
    ];
 | 
			
		||||
    $this->assertSame($allowed_values, $config_translation->get('settings.allowed_values'));
 | 
			
		||||
 | 
			
		||||
    $config_translation = $language_manager->getLanguageConfigOverride('is', 'field.storage.node.field_color');
 | 
			
		||||
    $allowed_values = [
 | 
			
		||||
      0 => [
 | 
			
		||||
        'label' => 'Grænn',
 | 
			
		||||
      ],
 | 
			
		||||
      1 => [
 | 
			
		||||
        'label' => 'Svartur',
 | 
			
		||||
      ],
 | 
			
		||||
      2 => [
 | 
			
		||||
        'label' => 'Hvítur',
 | 
			
		||||
      ],
 | 
			
		||||
    ];
 | 
			
		||||
    $this->assertSame($allowed_values, $config_translation->get('settings.allowed_values'));
 | 
			
		||||
 | 
			
		||||
    $config_translation = $language_manager->getLanguageConfigOverride('fr', 'field.storage.node.field_rating');
 | 
			
		||||
    $allowed_values = [
 | 
			
		||||
      1 => [
 | 
			
		||||
        'label' => 'Haute',
 | 
			
		||||
      ],
 | 
			
		||||
      2 => [
 | 
			
		||||
        'label' => 'Moyenne',
 | 
			
		||||
      ],
 | 
			
		||||
      3 => [
 | 
			
		||||
        'label' => 'Faible',
 | 
			
		||||
      ],
 | 
			
		||||
    ];
 | 
			
		||||
    $this->assertSame($allowed_values, $config_translation->get('settings.allowed_values'));
 | 
			
		||||
 | 
			
		||||
    $config_translation = $language_manager->getLanguageConfigOverride('is', 'field.storage.node.field_rating');
 | 
			
		||||
    $allowed_values = [
 | 
			
		||||
      1 => [
 | 
			
		||||
        'label' => 'Hár',
 | 
			
		||||
      ],
 | 
			
		||||
      2 => [
 | 
			
		||||
        'label' => 'Miðlungs',
 | 
			
		||||
      ],
 | 
			
		||||
      3 => [
 | 
			
		||||
        'label' => 'Lágt',
 | 
			
		||||
      ],
 | 
			
		||||
    ];
 | 
			
		||||
    $this->assertSame($allowed_values, $config_translation->get('settings.allowed_values'));
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,230 @@
 | 
			
		|||
<?php
 | 
			
		||||
 | 
			
		||||
namespace Drupal\Tests\field\Kernel\Plugin\migrate\source\d7;
 | 
			
		||||
 | 
			
		||||
use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Tests the field option translation source plugin.
 | 
			
		||||
 *
 | 
			
		||||
 * @covers \Drupal\field\Plugin\migrate\source\d7\FieldOptionTranslation
 | 
			
		||||
 * @group migrate_drupal
 | 
			
		||||
 */
 | 
			
		||||
class FieldOptionTranslationTest extends MigrateSqlSourceTestBase {
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * {@inheritdoc}
 | 
			
		||||
   */
 | 
			
		||||
  public static $modules = ['field', 'migrate_drupal'];
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * {@inheritdoc}
 | 
			
		||||
   */
 | 
			
		||||
  public function providerSource() {
 | 
			
		||||
    $test = [];
 | 
			
		||||
 | 
			
		||||
    // The source data.
 | 
			
		||||
    $test[0]['source_data']['field_config'] = [
 | 
			
		||||
      [
 | 
			
		||||
        'id' => '4',
 | 
			
		||||
        'field_name' => 'field_color',
 | 
			
		||||
        'type' => 'list_text',
 | 
			
		||||
        'module' => 'list',
 | 
			
		||||
        'active' => '1',
 | 
			
		||||
        'storage_type' => 'field_sql_storage',
 | 
			
		||||
        'storage_module' => 'field_sql_storage',
 | 
			
		||||
        'storage_active' => '1',
 | 
			
		||||
        'locked' => '0',
 | 
			
		||||
        'data' => 'a:7:{s:12:"translatable";b:1;s:12:"entity_types";a:0:{}s:8:"settings";a:3:{s:14:"allowed_values";a:3:{i:0;s:5:"Green";i:1;s:5:"Black";i:2;s:5:"White";}s:23:"allowed_values_function";s:0:"";s:23:"entity_translation_sync";b:0;}s:7:"storage";a:5:{s:4:"type";s:17:"field_sql_storage";s:8:"settings";a:0:{}s:6:"module";s:17:"field_sql_storage";s:6:"active";s:1:"1";s:7:"details";a:1:{s:3:"sql";a:2:{s:18:"FIELD_LOAD_CURRENT";a:1:{s:22:"field_data_field_color";a:1:{s:5:"value";s:17:"field_color_value";}}s:19:"FIELD_LOAD_REVISION";a:1:{s:26:"field_revision_field_color";a:1:{s:5:"value";s:17:"field_color_value";}}}}}s:12:"foreign keys";a:0:{}s:7:"indexes";a:1:{s:5:"value";a:1:{i:0;s:5:"value";}}s:2:"id";s:2:"48";}',
 | 
			
		||||
        'cardinality' => '1',
 | 
			
		||||
        'translatable' => '1',
 | 
			
		||||
        'deleted' => '0',
 | 
			
		||||
      ],
 | 
			
		||||
      [
 | 
			
		||||
        'id' => '2',
 | 
			
		||||
        'field_name' => 'field_rating',
 | 
			
		||||
        'type' => 'list_text',
 | 
			
		||||
        'module' => 'list',
 | 
			
		||||
        'active' => '1',
 | 
			
		||||
        'storage_type' => 'field_sql_storage',
 | 
			
		||||
        'storage_module' => 'field_sql_storage',
 | 
			
		||||
        'storage_active' => '1',
 | 
			
		||||
        'locked' => '0',
 | 
			
		||||
        'data' => 'a:7:{s:12:"translatable";b:1;s:12:"entity_types";a:0:{}s:8:"settings";a:3:{s:14:"allowed_values";a:3:{i:1;s:4:"High";i:2;s:6:"Medium";i:3;s:3:"Low";}s:23:"allowed_values_function";s:0:"";s:23:"entity_translation_sync";b:0;}s:7:"storage";a:5:{s:4:"type";s:17:"field_sql_storage";s:8:"settings";a:0:{}s:6:"module";s:17:"field_sql_storage";s:6:"active";s:1:"1";s:7:"details";a:1:{s:3:"sql";a:2:{s:18:"FIELD_LOAD_CURRENT";a:1:{s:23:"field_data_field_rating";a:1:{s:5:"value";s:18:"field_rating_value";}}s:19:"FIELD_LOAD_REVISION";a:1:{s:27:"field_revision_field_rating";a:1:{s:5:"value";s:18:"field_rating_value";}}}}}s:12:"foreign keys";a:0:{}s:7:"indexes";a:1:{s:5:"value";a:1:{i:0;s:5:"value";}}s:2:"id";s:2:"49";}',
 | 
			
		||||
        'cardinality' => '1',
 | 
			
		||||
        'translatable' => '1',
 | 
			
		||||
        'deleted' => '0',
 | 
			
		||||
      ],
 | 
			
		||||
    ];
 | 
			
		||||
    $test[0]['source_data']['field_config_instance'] = [
 | 
			
		||||
      [
 | 
			
		||||
        'id' => '76',
 | 
			
		||||
        'field_id' => '4',
 | 
			
		||||
        'field_name' => 'field_color',
 | 
			
		||||
        'entity_type' => 'node',
 | 
			
		||||
        'bundle' => 'blog',
 | 
			
		||||
        'data' => 'a:7:{s:5:"label";s:5:"Color";s:6:"widget";a:5:{s:6:"weight";s:2:"11";s:4:"type";s:14:"options_select";s:6:"module";s:7:"options";s:6:"active";i:1;s:8:"settings";a:0:{}}s:8:"settings";a:2:{s:18:"user_register_form";b:0;s:23:"entity_translation_sync";b:0;}s:7:"display";a:1:{s:7:"default";a:5:{s:5:"label";s:5:"above";s:4:"type";s:12:"list_default";s:8:"settings";a:0:{}s:6:"module";s:4:"list";s:6:"weight";i:10;}}s:8:"required";i:0;s:11:"description";s:0:"";s:13:"default_value";N;}',
 | 
			
		||||
        'deleted' => '0',
 | 
			
		||||
      ],
 | 
			
		||||
      [
 | 
			
		||||
        'id' => '77',
 | 
			
		||||
        'field_id' => '2',
 | 
			
		||||
        'field_name' => 'field_rating',
 | 
			
		||||
        'entity_type' => 'node',
 | 
			
		||||
        'bundle' => 'blog',
 | 
			
		||||
        'data' => 'a:7:{s:5:"label";s:6:"Rating";s:6:"widget";a:5:{s:6:"weight";s:2:"12";s:4:"type";s:15:"options_buttons";s:6:"module";s:7:"options";s:6:"active";i:1;s:8:"settings";a:0:{}}s:8:"settings";a:2:{s:18:"user_register_form";b:0;s:23:"entity_translation_sync";b:0;}s:7:"display";a:1:{s:7:"default";a:5:{s:5:"label";s:5:"above";s:4:"type";s:12:"list_default";s:8:"settings";a:0:{}s:6:"module";s:4:"list";s:6:"weight";i:11;}}s:8:"required";i:0;s:11:"description";s:0:"";s:13:"default_value";N;}',
 | 
			
		||||
        'deleted' => '0',
 | 
			
		||||
      ],
 | 
			
		||||
    ];
 | 
			
		||||
 | 
			
		||||
    $test[0]['source_data']['i18n_string'] = [
 | 
			
		||||
      [
 | 
			
		||||
        'lid' => '764',
 | 
			
		||||
        'textgroup' => 'field',
 | 
			
		||||
        'context' => 'field_color:blog:label',
 | 
			
		||||
        'objectid' => 'blog',
 | 
			
		||||
        'type' => 'field_color',
 | 
			
		||||
        'property' => 'label',
 | 
			
		||||
        'objectindex' => '0',
 | 
			
		||||
        'format' => '',
 | 
			
		||||
      ],
 | 
			
		||||
      [
 | 
			
		||||
        'lid' => '1',
 | 
			
		||||
        'textgroup' => 'field',
 | 
			
		||||
        'context' => 'field_rating:#allowed_values:1',
 | 
			
		||||
        'objectid' => '#allowed_values',
 | 
			
		||||
        'type' => 'field_rating',
 | 
			
		||||
        'property' => '1',
 | 
			
		||||
        'objectindex' => '0',
 | 
			
		||||
        'format' => '',
 | 
			
		||||
      ],
 | 
			
		||||
      [
 | 
			
		||||
        'lid' => '2',
 | 
			
		||||
        'textgroup' => 'field',
 | 
			
		||||
        'context' => 'field_rating:#allowed_values:2',
 | 
			
		||||
        'objectid' => '#allowed_values',
 | 
			
		||||
        'type' => 'field_rating',
 | 
			
		||||
        'property' => '2',
 | 
			
		||||
        'objectindex' => '0',
 | 
			
		||||
        'format' => '',
 | 
			
		||||
      ],
 | 
			
		||||
      [
 | 
			
		||||
        'lid' => '3',
 | 
			
		||||
        'textgroup' => 'field',
 | 
			
		||||
        'context' => 'field_rating:#allowed_values:3',
 | 
			
		||||
        'objectid' => '#allowed_values',
 | 
			
		||||
        'type' => 'field_rating',
 | 
			
		||||
        'property' => '3',
 | 
			
		||||
        'objectindex' => '0',
 | 
			
		||||
        'format' => '',
 | 
			
		||||
      ],
 | 
			
		||||
    ];
 | 
			
		||||
    $test[0]['source_data']['locales_target'] = [
 | 
			
		||||
      [
 | 
			
		||||
        'lid' => '764',
 | 
			
		||||
        'translation' => 'Color',
 | 
			
		||||
        'language' => 'fr',
 | 
			
		||||
        'plid' => '0',
 | 
			
		||||
        'plural' => '0',
 | 
			
		||||
        'i18n_status' => '0',
 | 
			
		||||
      ],
 | 
			
		||||
      [
 | 
			
		||||
        'lid' => '1',
 | 
			
		||||
        'translation' => 'Haute',
 | 
			
		||||
        'language' => 'fr',
 | 
			
		||||
        'plid' => '0',
 | 
			
		||||
        'plural' => '0',
 | 
			
		||||
        'i18n_status' => '0',
 | 
			
		||||
      ],
 | 
			
		||||
      [
 | 
			
		||||
        'lid' => '2',
 | 
			
		||||
        'translation' => 'Moyenne',
 | 
			
		||||
        'language' => 'fr',
 | 
			
		||||
        'plid' => '0',
 | 
			
		||||
        'plural' => '0',
 | 
			
		||||
        'i18n_status' => '0',
 | 
			
		||||
      ],
 | 
			
		||||
      [
 | 
			
		||||
        'lid' => '3',
 | 
			
		||||
        'translation' => 'Faible',
 | 
			
		||||
        'language' => 'fr',
 | 
			
		||||
        'plid' => '0',
 | 
			
		||||
        'plural' => '0',
 | 
			
		||||
        'i18n_status' => '0',
 | 
			
		||||
      ],
 | 
			
		||||
      [
 | 
			
		||||
        'lid' => '768',
 | 
			
		||||
        'translation' => 'Rating',
 | 
			
		||||
        'language' => 'fr',
 | 
			
		||||
        'plid' => '0',
 | 
			
		||||
        'plural' => '0',
 | 
			
		||||
        'i18n_status' => '0',
 | 
			
		||||
      ],
 | 
			
		||||
    ];
 | 
			
		||||
    $test[0]['expected_results'] = [
 | 
			
		||||
      [
 | 
			
		||||
        'i18n_lid' => '1',
 | 
			
		||||
        'textgroup' => 'field',
 | 
			
		||||
        'context' => 'field_rating:#allowed_values:1',
 | 
			
		||||
        'objectid' => '#allowed_values',
 | 
			
		||||
        'type' => 'list_text',
 | 
			
		||||
        'property' => '1',
 | 
			
		||||
        'objectindex' => '0',
 | 
			
		||||
        'format' => '',
 | 
			
		||||
        'language' => 'fr',
 | 
			
		||||
        'translation' => 'Haute',
 | 
			
		||||
        'plid' => 0,
 | 
			
		||||
        'plural' => 0,
 | 
			
		||||
        'i18n_status' => 0,
 | 
			
		||||
        'field_name' => 'field_rating',
 | 
			
		||||
        'data' => 'a:7:{s:12:"translatable";b:1;s:12:"entity_types";a:0:{}s:8:"settings";a:3:{s:14:"allowed_values";a:3:{i:1;s:4:"High";i:2;s:6:"Medium";i:3;s:3:"Low";}s:23:"allowed_values_function";s:0:"";s:23:"entity_translation_sync";b:0;}s:7:"storage";a:5:{s:4:"type";s:17:"field_sql_storage";s:8:"settings";a:0:{}s:6:"module";s:17:"field_sql_storage";s:6:"active";s:1:"1";s:7:"details";a:1:{s:3:"sql";a:2:{s:18:"FIELD_LOAD_CURRENT";a:1:{s:23:"field_data_field_rating";a:1:{s:5:"value";s:18:"field_rating_value";}}s:19:"FIELD_LOAD_REVISION";a:1:{s:27:"field_revision_field_rating";a:1:{s:5:"value";s:18:"field_rating_value";}}}}}s:12:"foreign keys";a:0:{}s:7:"indexes";a:1:{s:5:"value";a:1:{i:0;s:5:"value";}}s:2:"id";s:2:"49";}',
 | 
			
		||||
        'bundle' => 'blog',
 | 
			
		||||
        'entity_type' => 'node',
 | 
			
		||||
        'i18n_type' => 'field_rating',
 | 
			
		||||
      ],
 | 
			
		||||
      [
 | 
			
		||||
        'i18n_lid' => '2',
 | 
			
		||||
        'textgroup' => 'field',
 | 
			
		||||
        'context' => 'field_rating:#allowed_values:2',
 | 
			
		||||
        'objectid' => '#allowed_values',
 | 
			
		||||
        'type' => 'list_text',
 | 
			
		||||
        'property' => '2',
 | 
			
		||||
        'objectindex' => '0',
 | 
			
		||||
        'format' => '',
 | 
			
		||||
        'language' => 'fr',
 | 
			
		||||
        'translation' => 'Moyenne',
 | 
			
		||||
        'plid' => 0,
 | 
			
		||||
        'plural' => 0,
 | 
			
		||||
        'i18n_status' => 0,
 | 
			
		||||
        'field_name' => 'field_rating',
 | 
			
		||||
        'data' => 'a:7:{s:12:"translatable";b:1;s:12:"entity_types";a:0:{}s:8:"settings";a:3:{s:14:"allowed_values";a:3:{i:1;s:4:"High";i:2;s:6:"Medium";i:3;s:3:"Low";}s:23:"allowed_values_function";s:0:"";s:23:"entity_translation_sync";b:0;}s:7:"storage";a:5:{s:4:"type";s:17:"field_sql_storage";s:8:"settings";a:0:{}s:6:"module";s:17:"field_sql_storage";s:6:"active";s:1:"1";s:7:"details";a:1:{s:3:"sql";a:2:{s:18:"FIELD_LOAD_CURRENT";a:1:{s:23:"field_data_field_rating";a:1:{s:5:"value";s:18:"field_rating_value";}}s:19:"FIELD_LOAD_REVISION";a:1:{s:27:"field_revision_field_rating";a:1:{s:5:"value";s:18:"field_rating_value";}}}}}s:12:"foreign keys";a:0:{}s:7:"indexes";a:1:{s:5:"value";a:1:{i:0;s:5:"value";}}s:2:"id";s:2:"49";}',
 | 
			
		||||
        'bundle' => 'blog',
 | 
			
		||||
        'entity_type' => 'node',
 | 
			
		||||
        'i18n_type' => 'field_rating',
 | 
			
		||||
      ],
 | 
			
		||||
      [
 | 
			
		||||
        'i18n_lid' => '3',
 | 
			
		||||
        'textgroup' => 'field',
 | 
			
		||||
        'context' => 'field_rating:#allowed_values:3',
 | 
			
		||||
        'objectid' => '#allowed_values',
 | 
			
		||||
        'type' => 'list_text',
 | 
			
		||||
        'property' => '3',
 | 
			
		||||
        'objectindex' => '0',
 | 
			
		||||
        'format' => '',
 | 
			
		||||
        'language' => 'fr',
 | 
			
		||||
        'translation' => 'Faible',
 | 
			
		||||
        'plid' => 0,
 | 
			
		||||
        'plural' => 0,
 | 
			
		||||
        'i18n_status' => 0,
 | 
			
		||||
        'field_name' => 'field_rating',
 | 
			
		||||
        'data' => 'a:7:{s:12:"translatable";b:1;s:12:"entity_types";a:0:{}s:8:"settings";a:3:{s:14:"allowed_values";a:3:{i:1;s:4:"High";i:2;s:6:"Medium";i:3;s:3:"Low";}s:23:"allowed_values_function";s:0:"";s:23:"entity_translation_sync";b:0;}s:7:"storage";a:5:{s:4:"type";s:17:"field_sql_storage";s:8:"settings";a:0:{}s:6:"module";s:17:"field_sql_storage";s:6:"active";s:1:"1";s:7:"details";a:1:{s:3:"sql";a:2:{s:18:"FIELD_LOAD_CURRENT";a:1:{s:23:"field_data_field_rating";a:1:{s:5:"value";s:18:"field_rating_value";}}s:19:"FIELD_LOAD_REVISION";a:1:{s:27:"field_revision_field_rating";a:1:{s:5:"value";s:18:"field_rating_value";}}}}}s:12:"foreign keys";a:0:{}s:7:"indexes";a:1:{s:5:"value";a:1:{i:0;s:5:"value";}}s:2:"id";s:2:"49";}',
 | 
			
		||||
        'bundle' => 'blog',
 | 
			
		||||
        'entity_type' => 'node',
 | 
			
		||||
        'i18n_type' => 'field_rating',
 | 
			
		||||
      ],
 | 
			
		||||
    ];
 | 
			
		||||
 | 
			
		||||
    return $test;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -4991,6 +4991,15 @@ $connection->insert('field_config_instance')
 | 
			
		|||
  'data' => 'a:7:{s:5:"label";s:6:"Rating";s:6:"widget";a:5:{s:6:"weight";s:2:"12";s:4:"type";s:15:"options_buttons";s:6:"module";s:7:"options";s:6:"active";i:1;s:8:"settings";a:0:{}}s:8:"settings";a:2:{s:18:"user_register_form";b:0;s:23:"entity_translation_sync";b:0;}s:7:"display";a:1:{s:7:"default";a:5:{s:5:"label";s:5:"above";s:4:"type";s:12:"list_default";s:8:"settings";a:0:{}s:6:"module";s:4:"list";s:6:"weight";i:11;}}s:8:"required";i:0;s:11:"description";s:0:"";s:13:"default_value";N;}',
 | 
			
		||||
  'deleted' => '0',
 | 
			
		||||
))
 | 
			
		||||
->values(array(
 | 
			
		||||
  'id' => '78',
 | 
			
		||||
  'field_id' => '6',
 | 
			
		||||
  'field_name' => 'field_boolean',
 | 
			
		||||
  'entity_type' => 'node',
 | 
			
		||||
  'bundle' => 'blog',
 | 
			
		||||
  'data' => 'a:6:{s:5:"label";s:7:"Boolean";s:6:"widget";a:4:{s:4:"type";s:13:"options_onoff";s:6:"weight";s:2:"14";s:8:"settings";a:1:{s:13:"display_label";i:0;}s:6:"module";s:7:"options";}s:8:"settings";a:2:{s:18:"user_register_form";b:0;s:23:"entity_translation_sync";b:0;}s:7:"display";a:1:{s:7:"default";a:5:{s:5:"label";s:5:"above";s:4:"type";s:12:"list_default";s:8:"settings";a:0:{}s:6:"module";s:4:"list";s:6:"weight";i:12;}}s:8:"required";b:0;s:11:"description";s:0:"";}',
 | 
			
		||||
  'deleted' => '0',
 | 
			
		||||
))
 | 
			
		||||
->execute();
 | 
			
		||||
$connection->schema()->createTable('field_data_body', array(
 | 
			
		||||
  'fields' => array(
 | 
			
		||||
| 
						 | 
				
			
			@ -5494,7 +5503,17 @@ $connection->insert('field_data_field_boolean')
 | 
			
		|||
  'deleted' => '0',
 | 
			
		||||
  'entity_id' => '1',
 | 
			
		||||
  'revision_id' => '1',
 | 
			
		||||
  'language' => 'und',
 | 
			
		||||
  'language' => 'fr',
 | 
			
		||||
  'delta' => '0',
 | 
			
		||||
  'field_boolean_value' => '1',
 | 
			
		||||
))
 | 
			
		||||
->values(array(
 | 
			
		||||
  'entity_type' => 'node',
 | 
			
		||||
  'bundle' => 'test_content_type',
 | 
			
		||||
  'deleted' => '0',
 | 
			
		||||
  'entity_id' => '1',
 | 
			
		||||
  'revision_id' => '1',
 | 
			
		||||
  'language' => 'is',
 | 
			
		||||
  'delta' => '0',
 | 
			
		||||
  'field_boolean_value' => '1',
 | 
			
		||||
))
 | 
			
		||||
| 
						 | 
				
			
			@ -10595,7 +10614,27 @@ $connection->insert('field_revision_field_boolean')
 | 
			
		|||
  'deleted' => '0',
 | 
			
		||||
  'entity_id' => '1',
 | 
			
		||||
  'revision_id' => '1',
 | 
			
		||||
  'language' => 'und',
 | 
			
		||||
  'language' => 'en',
 | 
			
		||||
  'delta' => '0',
 | 
			
		||||
  'field_boolean_value' => '1',
 | 
			
		||||
))
 | 
			
		||||
->values(array(
 | 
			
		||||
  'entity_type' => 'node',
 | 
			
		||||
  'bundle' => 'test_content_type',
 | 
			
		||||
  'deleted' => '0',
 | 
			
		||||
  'entity_id' => '1',
 | 
			
		||||
  'revision_id' => '1',
 | 
			
		||||
  'language' => 'fr',
 | 
			
		||||
  'delta' => '0',
 | 
			
		||||
  'field_boolean_value' => '1',
 | 
			
		||||
))
 | 
			
		||||
->values(array(
 | 
			
		||||
  'entity_type' => 'node',
 | 
			
		||||
  'bundle' => 'test_content_type',
 | 
			
		||||
  'deleted' => '0',
 | 
			
		||||
  'entity_id' => '1',
 | 
			
		||||
  'revision_id' => '1',
 | 
			
		||||
  'language' => 'is',
 | 
			
		||||
  'delta' => '0',
 | 
			
		||||
  'field_boolean_value' => '1',
 | 
			
		||||
))
 | 
			
		||||
| 
						 | 
				
			
			@ -18873,6 +18912,22 @@ $connection->insert('locales_target')
 | 
			
		|||
  'plural' => '0',
 | 
			
		||||
  'i18n_status' => '0',
 | 
			
		||||
))
 | 
			
		||||
->values(array(
 | 
			
		||||
  'lid' => '687',
 | 
			
		||||
  'translation' => 'is - Off',
 | 
			
		||||
  'language' => 'is',
 | 
			
		||||
  'plid' => '0',
 | 
			
		||||
  'plural' => '0',
 | 
			
		||||
  'i18n_status' => '0',
 | 
			
		||||
))
 | 
			
		||||
->values(array(
 | 
			
		||||
  'lid' => '688',
 | 
			
		||||
  'translation' => 'is - 1',
 | 
			
		||||
  'language' => 'is',
 | 
			
		||||
  'plid' => '0',
 | 
			
		||||
  'plural' => '0',
 | 
			
		||||
  'i18n_status' => '0',
 | 
			
		||||
))
 | 
			
		||||
->values(array(
 | 
			
		||||
  'lid' => '87',
 | 
			
		||||
  'translation' => 'is - VocabTranslate',
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -74,7 +74,7 @@ class Upgrade7Test extends MigrateUpgradeExecuteTestBase {
 | 
			
		|||
      'contact_form' => 3,
 | 
			
		||||
      'contact_message' => 0,
 | 
			
		||||
      'editor' => 2,
 | 
			
		||||
      'field_config' => 72,
 | 
			
		||||
      'field_config' => 73,
 | 
			
		||||
      'field_storage_config' => 55,
 | 
			
		||||
      'file' => 3,
 | 
			
		||||
      'filter_format' => 7,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue