summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGábor Hojtsy2018-06-27 14:43:04 (GMT)
committerGábor Hojtsy2018-06-27 14:43:04 (GMT)
commit9319cfd19a8b9a12cba1c1d65edd121b41f3a184 (patch)
tree68fec234f9c281162b107c13e70b2a24f3a8d062
parent05a11424fcc480aff2401fcbf52cd80afeba555c (diff)
Issue #2225681 by quietone, Jo Fitzgerald, dipakmdhrm, Adita, RytoEX, maxocub, Gábor Hojtsy, phenaproxima, heddn, masipila, iMiksu, ao2, catch, alexpott, xjm: Migrate D6 i18n blocks translated strings
-rw-r--r--core/modules/block/src/Plugin/migrate/source/d6/BlockTranslation.php71
-rw-r--r--core/modules/block/tests/src/Kernel/Migrate/d6/MigrateBlockContentTranslationTest.php63
-rw-r--r--core/modules/block/tests/src/Kernel/Migrate/d6/MigrateBlockTest.php4
-rw-r--r--core/modules/block/tests/src/Kernel/Plugin/migrate/source/d6/BlockTranslationTest.php79
-rw-r--r--core/modules/content_translation/migrations/d6_block_translation.yml69
-rw-r--r--core/modules/migrate_drupal/tests/fixtures/drupal6.php41
-rw-r--r--core/modules/migrate_drupal_ui/tests/src/Functional/d6/MigrateUpgrade6ReviewPageTest.php2
-rw-r--r--core/modules/migrate_drupal_ui/tests/src/Functional/d6/MigrateUpgrade6Test.php2
8 files changed, 326 insertions, 5 deletions
diff --git a/core/modules/block/src/Plugin/migrate/source/d6/BlockTranslation.php b/core/modules/block/src/Plugin/migrate/source/d6/BlockTranslation.php
new file mode 100644
index 0000000..1d65cdd
--- /dev/null
+++ b/core/modules/block/src/Plugin/migrate/source/d6/BlockTranslation.php
@@ -0,0 +1,71 @@
+<?php
+
+namespace Drupal\block\Plugin\migrate\source\d6;
+
+use Drupal\block\Plugin\migrate\source\Block;
+use Drupal\migrate\Plugin\migrate\source\SourcePluginBase;
+use Drupal\migrate\Row;
+
+/**
+ * Gets i18n block data from source database.
+ *
+ * @MigrateSource(
+ * id = "d6_block_translation",
+ * source_module = "i18nblocks"
+ * )
+ */
+class BlockTranslation extends Block {
+
+ /**
+ * {@inheritdoc}
+ */
+ public function query() {
+ // Let the parent set the block table to use, but do not use the parent
+ // query. Instead build a query so can use an inner join to the selected
+ // block table.
+ parent::query();
+ $query = $this->select('i18n_blocks', 'i18n')
+ ->fields('i18n')
+ ->fields('b', ['bid', 'module', 'delta', 'theme', 'title']);
+ $query->innerJoin($this->blockTable, 'b', ('b.module = i18n.module AND b.delta = i18n.delta'));
+ return $query;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function fields() {
+ return [
+ 'bid' => $this->t('The block numeric identifier.'),
+ 'ibid' => $this->t('The i18n_blocks block numeric identifier.'),
+ 'module' => $this->t('The module providing the block.'),
+ 'delta' => $this->t("The block's delta."),
+ 'type' => $this->t('Block type'),
+ 'language' => $this->t('Language for this field.'),
+ 'theme' => $this->t('Which theme the block is placed in.'),
+ 'default_theme' => $this->t('The default theme.'),
+ 'title' => $this->t('Block title.'),
+ ];
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function prepareRow(Row $row) {
+ $row->setSourceProperty('default_theme', $this->defaultTheme);
+ return SourcePluginBase::prepareRow($row);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getIds() {
+ $ids = parent::getIds();
+ $ids['module']['alias'] = 'b';
+ $ids['delta']['alias'] = 'b';
+ $ids['theme']['alias'] = 'b';
+ $ids['language']['type'] = 'string';
+ return $ids;
+ }
+
+}
diff --git a/core/modules/block/tests/src/Kernel/Migrate/d6/MigrateBlockContentTranslationTest.php b/core/modules/block/tests/src/Kernel/Migrate/d6/MigrateBlockContentTranslationTest.php
new file mode 100644
index 0000000..e9f1e87
--- /dev/null
+++ b/core/modules/block/tests/src/Kernel/Migrate/d6/MigrateBlockContentTranslationTest.php
@@ -0,0 +1,63 @@
+<?php
+
+namespace Drupal\Tests\block\Kernel\Migrate\d6;
+
+use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
+
+/**
+ * Tests migration of i18n block translations.
+ *
+ * @group migrate_drupal_6
+ */
+class MigrateBlockContentTranslationTest extends MigrateDrupal6TestBase {
+
+ /**
+ * {@inheritdoc}
+ */
+ public static $modules = [
+ 'aggregator',
+ 'book',
+ 'block',
+ 'comment',
+ 'forum',
+ 'views',
+ 'block_content',
+ 'content_translation',
+ 'language',
+ 'statistics',
+ 'taxonomy',
+ ];
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function setUp() {
+ parent::setUp();
+ $this->installConfig(['block']);
+ $this->installConfig(['block_content']);
+ $this->installEntitySchema('block_content');
+
+ $this->executeMigrations([
+ 'd6_filter_format',
+ 'block_content_type',
+ 'block_content_body_field',
+ 'd6_custom_block',
+ 'd6_user_role',
+ 'd6_block',
+ 'd6_block_translation',
+ ]);
+ block_rebuild();
+ }
+
+ /**
+ * Tests the migration of block title translation.
+ */
+ public function testBlockContentTranslation() {
+ /** @var \Drupal\language\ConfigurableLanguageManagerInterface $language_manager */
+ $language_manager = $this->container->get('language_manager');
+
+ $config = $language_manager->getLanguageConfigOverride('zu', 'block.block.user_1');
+ $this->assertSame('zu - Navigation', $config->get('settings.label'));
+ }
+
+}
diff --git a/core/modules/block/tests/src/Kernel/Migrate/d6/MigrateBlockTest.php b/core/modules/block/tests/src/Kernel/Migrate/d6/MigrateBlockTest.php
index bb59f50..e0876fd 100644
--- a/core/modules/block/tests/src/Kernel/Migrate/d6/MigrateBlockTest.php
+++ b/core/modules/block/tests/src/Kernel/Migrate/d6/MigrateBlockTest.php
@@ -116,9 +116,9 @@ class MigrateBlockTest extends MigrateDrupal6TestBase {
$visibility = [];
$settings = [
'id' => 'system_menu_block',
- 'label' => '',
+ 'label' => 'zu - Navigation',
'provider' => 'system',
- 'label_display' => '0',
+ 'label_display' => 'visible',
'level' => 1,
'depth' => 0,
];
diff --git a/core/modules/block/tests/src/Kernel/Plugin/migrate/source/d6/BlockTranslationTest.php b/core/modules/block/tests/src/Kernel/Plugin/migrate/source/d6/BlockTranslationTest.php
new file mode 100644
index 0000000..445f32c
--- /dev/null
+++ b/core/modules/block/tests/src/Kernel/Plugin/migrate/source/d6/BlockTranslationTest.php
@@ -0,0 +1,79 @@
+<?php
+
+namespace Drupal\Tests\block\Kernel\Plugin\migrate\source\d6;
+
+use Drupal\Tests\block\Kernel\Plugin\migrate\source\BlockTest;
+
+/**
+ * Tests i18n block source plugin.
+ *
+ * @covers \Drupal\block\Plugin\migrate\source\d6\BlockTranslation
+ *
+ * @group content_translation
+ */
+class BlockTranslationTest extends BlockTest {
+
+ /**
+ * {@inheritdoc}
+ */
+ public static $modules = ['block'];
+
+ /**
+ * {@inheritdoc}
+ */
+ public function providerSource() {
+ // Test data is the same as BlockTest, but with the addition of i18n_blocks.
+ $tests = parent::providerSource();
+
+ // The source data.
+ $tests[0]['source_data']['i18n_blocks'] = [
+ [
+ 'ibid' => 1,
+ 'module' => 'block',
+ 'delta' => '1',
+ 'type' => 0,
+ 'language' => 'fr',
+ ],
+ [
+ 'ibid' => 2,
+ 'module' => 'block',
+ 'delta' => '2',
+ 'type' => 0,
+ 'language' => 'zu',
+ ],
+ ];
+ $tests[0]['source_data']['variables'] = [
+ [
+ 'name' => 'default_theme',
+ 'value' => 's:7:"garland";',
+ ],
+ ];
+ // The expected results.
+ $tests[0]['expected_data'] = [
+ [
+ 'bid' => 1,
+ 'module' => 'block',
+ 'delta' => '1',
+ 'title' => 'Test Title 01',
+ 'ibid' => 1,
+ 'type' => '0',
+ 'language' => 'fr',
+ 'default_theme' => 'Garland',
+ ],
+ [
+ 'bid' => 2,
+ 'module' => 'block',
+ 'delta' => '2',
+ 'theme' => 'garland',
+ 'title' => 'Test Title 02',
+ 'ibid' => 2,
+ 'type' => '0',
+ 'language' => 'zu',
+ 'default_theme' => 'Garland',
+ ],
+ ];
+
+ return $tests;
+ }
+
+}
diff --git a/core/modules/content_translation/migrations/d6_block_translation.yml b/core/modules/content_translation/migrations/d6_block_translation.yml
new file mode 100644
index 0000000..3f8810c
--- /dev/null
+++ b/core/modules/content_translation/migrations/d6_block_translation.yml
@@ -0,0 +1,69 @@
+id: d6_block_translation
+label: Block translations
+migration_tags:
+ - Drupal 6
+ - Configuration
+source:
+ plugin: d6_block_translation
+ constants:
+ dest_label: 'settings/label'
+process:
+ langcode: language
+ property: constants/dest_label
+ translation: title
+ id:
+ -
+ plugin: migration_lookup
+ migration: d6_block
+ source:
+ - module
+ - delta
+ -
+ plugin: skip_on_empty
+ method: row
+ plugin:
+ -
+ plugin: static_map
+ bypass: true
+ source:
+ - module
+ - delta
+ map:
+ book:
+ 0: book_navigation
+ comment:
+ 0: views_block:comments_recent-block_1
+ forum:
+ 0: forum_active_block
+ 1: forum_new_block
+ locale:
+ 0: language_block
+ node:
+ 0: node_syndicate_block
+ search:
+ 0: search_form_block
+ statistics:
+ 0: statistics_popular_block
+ system:
+ 0: system_powered_by_block
+ user:
+ 0: user_login_block
+ 1: system_menu_block:tools
+ 2: views_block:who_s_new-block_1
+ 3: views_block:who_s_online-who_s_online_block
+ -
+ plugin: block_plugin_id
+ -
+ plugin: skip_on_empty
+ method: row
+ theme:
+ plugin: block_theme
+ source:
+ - theme
+ - default_theme
+ - admin_theme
+destination:
+ plugin: entity:block
+migration_dependencies:
+ required:
+ - d6_block
diff --git a/core/modules/migrate_drupal/tests/fixtures/drupal6.php b/core/modules/migrate_drupal/tests/fixtures/drupal6.php
index 502e263..5793fd3 100644
--- a/core/modules/migrate_drupal/tests/fixtures/drupal6.php
+++ b/core/modules/migrate_drupal/tests/fixtures/drupal6.php
@@ -746,7 +746,7 @@ $connection->insert('blocks')
'throttle' => '0',
'visibility' => '0',
'pages' => '',
- 'title' => '',
+ 'title' => 'zu - Navigation',
'cache' => '-1',
))
->values(array(
@@ -8706,6 +8706,30 @@ $connection->schema()->createTable('i18n_blocks', array(
'mysql_character_set' => 'utf8',
));
+$connection->insert('i18n_blocks')
+->fields(array(
+ 'ibid',
+ 'module',
+ 'delta',
+ 'type',
+ 'language',
+))
+->values(array(
+ 'ibid' => '1',
+ 'module' => 'user',
+ 'delta' => '1',
+ 'type' => '0',
+ 'language' => 'zu',
+))
+->values(array(
+ 'ibid' => '2',
+ 'module' => 'menu',
+ 'delta' => 'menu-translation-test',
+ 'type' => '0',
+ 'language' => 'zu',
+))
+->execute();
+
$connection->schema()->createTable('i18n_strings', array(
'fields' => array(
'lid' => array(
@@ -9856,6 +9880,14 @@ $connection->insert('i18n_strings')
'objectindex' => '0',
'format' => '0',
))
+->values(array(
+ 'lid' => '1679',
+ 'objectid' => 'menu-translation-test',
+ 'type' => 'menu',
+ 'property' => 'title',
+ 'objectindex' => '0',
+ 'format' => '0',
+))
->execute();
$connection->schema()->createTable('i18n_variable', array(
@@ -22357,6 +22389,13 @@ $connection->insert('locales_source')
'source' => 'I really, really, really love migrating',
'version' => '1',
))
+->values(array(
+ 'lid' => '1679',
+ 'location' => 'menu:menu-translation-test:title',
+ 'textgroup' => 'menu',
+ 'source' => 'Translation test',
+ 'version' => '1',
+))
->execute();
$connection->schema()->createTable('locales_target', array(
diff --git a/core/modules/migrate_drupal_ui/tests/src/Functional/d6/MigrateUpgrade6ReviewPageTest.php b/core/modules/migrate_drupal_ui/tests/src/Functional/d6/MigrateUpgrade6ReviewPageTest.php
index 1eeb326..c62df12 100644
--- a/core/modules/migrate_drupal_ui/tests/src/Functional/d6/MigrateUpgrade6ReviewPageTest.php
+++ b/core/modules/migrate_drupal_ui/tests/src/Functional/d6/MigrateUpgrade6ReviewPageTest.php
@@ -60,6 +60,7 @@ class MigrateUpgrade6ReviewPageTest extends MigrateUpgradeReviewPageTestBase {
'filefield',
'filter',
'forum',
+ 'i18nblocks',
'i18ntaxonomy',
'imagecache',
'imagefield',
@@ -137,7 +138,6 @@ class MigrateUpgrade6ReviewPageTest extends MigrateUpgradeReviewPageTestBase {
'devel',
'devel_generate',
'devel_node_access',
- 'i18nblocks',
'i18ncck',
'i18ncontent',
'i18npoll',
diff --git a/core/modules/migrate_drupal_ui/tests/src/Functional/d6/MigrateUpgrade6Test.php b/core/modules/migrate_drupal_ui/tests/src/Functional/d6/MigrateUpgrade6Test.php
index abd6b89..ea1b26b 100644
--- a/core/modules/migrate_drupal_ui/tests/src/Functional/d6/MigrateUpgrade6Test.php
+++ b/core/modules/migrate_drupal_ui/tests/src/Functional/d6/MigrateUpgrade6Test.php
@@ -133,6 +133,7 @@ class MigrateUpgrade6Test extends MigrateUpgradeExecuteTestBase {
'filter',
'forum',
'i18nmenu',
+ 'i18nblocks',
'i18ntaxonomy',
'imagecache',
'imagefield',
@@ -174,7 +175,6 @@ class MigrateUpgrade6Test extends MigrateUpgradeExecuteTestBase {
*/
protected function getMissingPaths() {
return [
- 'i18nblocks',
'i18ncck',
'i18ncontent',
// This module is in the missing path list because it is installed on the