diff --git a/core/modules/language/migration_templates/d6_language_negotiation_settings.yml b/core/modules/language/migration_templates/d6_language_negotiation_settings.yml new file mode 100644 index 0000000..4a0c9ef --- /dev/null +++ b/core/modules/language/migration_templates/d6_language_negotiation_settings.yml @@ -0,0 +1,26 @@ +id: d6_language_negotiation_settings +label: Language negotiation settings +migration_tags: + - Drupal 6 +source: + plugin: variable + variables: + - language_negotiation + constants: + session_parameter: 'language' +process: + 'session/parameter': 'constants/session_parameter' + 'url/source': + plugin: static_map + source: language_negotiation + map: + # LANGUAGE_NEGOTIATION_NONE = 0 + # LANGUAGE_NEGOTIATION_PATH_DEFAULT = 1 + # LANGUAGE_NEGOTIATION_PATH = 2 + # LANGUAGE_NEGOTIATION_DOMAIN = 3 + 1: path_prefix + 2: path_prefix + 3: domain +destination: + plugin: config + config_name: language.negotiation diff --git a/core/modules/language/src/Tests/Migrate/d6/MigrateLanguageNegotiationSettingsTest.php b/core/modules/language/src/Tests/Migrate/d6/MigrateLanguageNegotiationSettingsTest.php new file mode 100644 index 0000000..2960c8e --- /dev/null +++ b/core/modules/language/src/Tests/Migrate/d6/MigrateLanguageNegotiationSettingsTest.php @@ -0,0 +1,89 @@ +sourceDatabase->update('variable') + ->fields(array('value' => serialize(0))) + ->condition('name', 'language_negotiation') + ->execute(); + + $this->executeMigration('d6_language_negotiation_settings'); + + $config = $this->config('language.negotiation'); + $this->assertIdentical($config->get('session.parameter'), NULL); + $this->assertIdentical($config->get('url.source'), NULL); + } + + /** + * Tests migration of language negotiation variables to language.negotiation.yml. + */ + public function testLanguageNegotiationWithDefaultPathPrefix() { + $this->sourceDatabase->update('variable') + ->fields(array('value' => serialize(1))) + ->condition('name', 'language_negotiation') + ->execute(); + + $this->executeMigration('d6_language_negotiation_settings'); + + $config = $this->config('language.negotiation'); + $this->assertIdentical($config->get('session.parameter'), 'language'); + $this->assertIdentical($config->get('url.source'), LanguageNegotiationUrl::CONFIG_PATH_PREFIX ); + } + + /** + * Tests migration of language negotiation variables to language.negotiation.yml. + */ + public function testLanguageNegotiationWithPathPrefix() { + $this->sourceDatabase->update('variable') + ->fields(array('value' => serialize(2))) + ->condition('name', 'language_negotiation') + ->execute(); + + $this->executeMigration('d6_language_negotiation_settings'); + + $config = $this->config('language.negotiation'); + $this->assertIdentical($config->get('session.parameter'), 'language'); + $this->assertIdentical($config->get('url.source'), LanguageNegotiationUrl::CONFIG_PATH_PREFIX); + } + + /** + * Tests migration of language negotiation variables to language.negotiation.yml. + */ + public function testLanguageNegotiationWithDomain() { + $this->sourceDatabase->update('variable') + ->fields(array('value' => serialize(3))) + ->condition('name', 'language_negotiation') + ->execute(); + + $this->executeMigration('d6_language_negotiation_settings'); + + $config = $this->config('language.negotiation'); + $this->assertIdentical($config->get('session.parameter'), 'language'); + $this->assertIdentical($config->get('url.source'), LanguageNegotiationUrl::CONFIG_DOMAIN); + } + +} diff --git a/core/modules/migrate_drupal/config/schema/migrate_drupal.source.schema.yml b/core/modules/migrate_drupal/config/schema/migrate_drupal.source.schema.yml index 6152f9e..9bb6839 100644 --- a/core/modules/migrate_drupal/config/schema/migrate_drupal.source.schema.yml +++ b/core/modules/migrate_drupal/config/schema/migrate_drupal.source.schema.yml @@ -38,6 +38,9 @@ migrate.source.variable: slash: type: string label: 'Slash' + session_parameter: + type: string + label: 'Session parameter' migrate.source.variable_multirow: type: migrate_source_sql diff --git a/core/modules/migrate_drupal/tests/fixtures/drupal6.php b/core/modules/migrate_drupal/tests/fixtures/drupal6.php index 0f60343..6b8fb84 100644 --- a/core/modules/migrate_drupal/tests/fixtures/drupal6.php +++ b/core/modules/migrate_drupal/tests/fixtures/drupal6.php @@ -33544,6 +33544,10 @@ 'value' => 'O:8:"stdClass":11:{s:8:"language";s:2:"en";s:4:"name";s:7:"English";s:6:"native";s:7:"English";s:9:"direction";s:1:"0";s:7:"enabled";i:1;s:7:"plurals";s:1:"0";s:7:"formula";s:0:"";s:6:"domain";s:0:"";s:6:"prefix";s:0:"";s:6:"weight";s:1:"0";s:10:"javascript";s:0:"";}', )) ->values(array( + 'name' => 'language_negotiation', + 'value' => 's:1:"2";', +)) +->values(array( 'name' => 'locale_cache_strings', 'value' => 'i:1;', ))