reverted: --- b/core/modules/comment/src/Plugin/migrate/destination/EntityComment.php +++ a/core/modules/comment/src/Plugin/migrate/destination/EntityComment.php @@ -5,7 +5,6 @@ use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Field\FieldTypePluginManagerInterface; -use Drupal\Core\Language\LanguageManagerInterface; use Drupal\Core\State\StateInterface; use Drupal\migrate\Plugin\MigrationInterface; use Drupal\migrate\Plugin\migrate\destination\EntityContentBase; @@ -48,8 +47,6 @@ * The storage for this entity type. * @param array $bundles * The list of bundles this entity type has. - * @param LanguageManagerInterface $language_manager - * The language manager. * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager * The entity manager service. * @param \Drupal\Core\Field\FieldTypePluginManagerInterface $field_type_manager @@ -57,8 +54,8 @@ * @param \Drupal\Core\State\StateInterface $state * The state storage object. */ + public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EntityStorageInterface $storage, array $bundles, EntityManagerInterface $entity_manager, FieldTypePluginManagerInterface $field_type_manager, StateInterface $state) { + parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $storage, $bundles, $entity_manager, $field_type_manager); - public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EntityStorageInterface $storage, array $bundles, LanguageManagerInterface $language_manager, EntityManagerInterface $entity_manager, FieldTypePluginManagerInterface $field_type_manager, StateInterface $state) { - parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $storage, $bundles, $language_manager, $entity_manager, $field_type_manager); $this->state = $state; } @@ -74,7 +71,6 @@ $migration, $container->get('entity.manager')->getStorage($entity_type), array_keys($container->get('entity.manager')->getBundleInfo($entity_type)), - $container->get('language_manager'), $container->get('entity.manager'), $container->get('plugin.manager.field.field_type'), $container->get('state') reverted: --- b/core/modules/config_translation/migration_templates/d6_i18n_block.yml +++ /dev/null @@ -1,68 +0,0 @@ -id: d6_i18n_block -label: i18n Blocks -migration_tags: - - Drupal 6 -source: - plugin: d6_i18n_block - constants: - dest_label: 'settings/label' -process: - langcode: language - property: constants/dest_label - translation: translation - id: - - - plugin: concat - source: - - module - - objectid - delimiter: _ - - - plugin: substr - length: 32 - 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 reverted: --- b/core/modules/config_translation/src/Plugin/migrate/process/I18nBlockSettings.php +++ /dev/null @@ -1,35 +0,0 @@ -getModuleSchemaVersion('system') >= 7000) { - $this->blockTable = 'block'; - } - else { - $this->blockTable = 'blocks'; - } - $query = $this->select('i18n_strings', 'i18n') - ->fields('i18n', ['lid', 'type', 'property', 'objectid']) - ->fields('lt', ['lid', 'language', 'translation']) - ->fields('b', ['bid', 'module', 'delta', 'theme']) - ->condition('i18n.type', 'block'); - $query->leftJoin($this->blockTable, 'b', 'b.bid = i18n.objectid'); - $query->leftJoin('locales_target', 'lt', 'lt.lid = i18n.lid'); - return $query; - } - - /** - * {@inheritdoc} - */ - protected function initializeIterator() { - $this->defaultTheme = $this->variableGet('theme_default', 'Garland'); - $this->adminTheme = $this->variableGet('admin_theme', NULL); - return parent::initializeIterator(); - } - - /** - * {@inheritdoc} - */ - public function fields() { - return [ - 'bid' => $this->t('The block numeric identifier.'), - 'module' => $this->t('The module providing the block.'), - 'delta' => $this->t("The block's delta."), - 'theme' => $this->t('Which theme the block is placed in.'), - 'language' => $this->t('Language for this field.'), - 'property' => $this->t('Name of property being translated.'), - 'translation' => $this->t('Translation of either the title or explanation.'), - ]; - } - - /** - * {@inheritdoc} - */ - public function getIds() { - $ids['module']['type'] = 'string'; - $ids['delta']['type'] = 'string'; - $ids['theme']['type'] = 'string'; - $ids['language']['type'] = 'string'; - return $ids; - } - - /** - * {@inheritdoc} - */ - public function prepareRow(Row $row) { - $row->setSourceProperty('default_theme', $this->defaultTheme); - $row->setSourceProperty('admin_theme', $this->adminTheme); - return parent::prepareRow($row); - } - -} reverted: --- b/core/modules/config_translation/tests/src/Kernel/Migrate/d6/MigrateI18nBlockTest.php +++ /dev/null @@ -1,66 +0,0 @@ -installConfig(['block_content']); - $this->installEntitySchema('block_content'); - - // Set Bartik and Seven as the default public and admin theme. - $config = $this->config('system.theme'); - $config->set('default', 'bartik'); - $config->set('admin', 'seven'); - $config->save(); - - // Install one of D8's test themes. - \Drupal::service('theme_handler')->install(['test_theme']); - - $this->executeMigrations([ - 'd6_filter_format', - 'block_content_type', - 'block_content_body_field', - 'menu', - 'd6_custom_block', - 'd6_user_role', - 'd6_block', - 'd6_i18n_block', - ]); - } - - /** - * Tests the migration of block title translation. - */ - public function testI18nBlock() { - $config = \Drupal::service('language_manager')->getLanguageConfigOverride('fr', 'block.block.user'); - $this->assertSame('fr - Static Block', $config->get('settings.label')); - $config = \Drupal::service('language_manager')->getLanguageConfigOverride('fr', 'block.block.user_1'); - $this->assertSame('Encore un bloc statique', $config->get('settings.label')); - } - -} reverted: --- b/core/modules/config_translation/tests/src/Kernel/Plugin/migrate/source/d6/I18nBlockSourceTest.php +++ /dev/null @@ -1,157 +0,0 @@ - 1, - 'module' => 'block', - 'delta' => '1', - 'theme' => 'garland', - 'status' => 1, - 'weight' => 0, - 'region' => 'left', - 'custom' => 0, - 'throttle' => 0, - 'visibility' => 1, - 'pages' => '', - 'title' => 'Test Title 01', - 'cache' => -1, - ], - [ - 'bid' => 2, - 'module' => 'block', - 'delta' => '2', - 'theme' => 'garland', - 'status' => 1, - 'weight' => 5, - 'region' => 'right', - 'custom' => 0, - 'throttle' => 0, - 'visibility' => 0, - 'pages' => '', - 'title' => 'Test Title 02', - 'cache' => -1, - ], - ]; - - $tests[0]['database']['i18n_strings'] = [ - [ - 'lid' => 1, - 'objectid' => 1, - 'type' => 'block', - 'property' => 'title', - 'objectindex' => 0, - 'format' => 0, - ], - [ - 'lid' => 2, - 'objectid' => 1, - 'type' => 'block', - 'property' => 'body', - 'objectindex' => 0, - 'format' => 0, - ], - [ - 'lid' => 3, - 'objectid' => 2, - 'type' => 'block', - 'property' => 'body', - 'objectindex' => 0, - 'format' => 2, - ], - ]; - - $tests[0]['database']['locales_target'] = [ - [ - 'lid' => 1, - 'language' => 'fr', - 'translation' => 'fr - title translation', - 'plid' => 0, - 'plural' => 0, - 'u18n_status' => 0, - ], - [ - 'lid' => 2, - 'language' => 'fr', - 'translation' => 'fr - description translation', - 'plid' => 0, - 'plural' => 0, - 'u18n_status' => 0, - ], - [ - 'lid' => 3, - 'language' => 'zu', - 'translation' => 'zu - description translation', - 'plid' => 0, - 'plural' => 0, - 'u18n_status' => 0, - ], - ]; - - $tests[0]['expectedResults'] = [ - [ - 'lid' => '1', - 'type' => 'block', - 'property' => 'title', - 'objectid' => '1', - 'lt_lid' => '1', - 'language' => 'fr', - 'translation' => 'fr - title translation', - 'bid' => '1', - 'module' => 'block', - 'delta' => '1', - ], - [ - 'lid' => '2', - 'type' => 'block', - 'property' => 'body', - 'objectid' => '1', - 'lt_lid' => '2', - 'language' => 'fr', - 'translation' => 'fr - description translation', - 'bid' => '1', - 'module' => 'block', - 'delta' => '1', - ], - [ - 'lid' => '3', - 'type' => 'block', - 'property' => 'body', - 'objectid' => '2', - 'lt_lid' => '3', - 'language' => 'zu', - 'translation' => 'zu - description translation', - 'bid' => '2', - 'module' => 'block', - 'delta' => '2', - ], - ]; - - return $tests; - } - -} diff -u b/core/modules/content_translation/tests/src/Kernel/Migrate/d6/MigrateI18nBlockContentTest.php b/core/modules/content_translation/tests/src/Kernel/Migrate/d6/MigrateI18nBlockContentTest.php --- b/core/modules/content_translation/tests/src/Kernel/Migrate/d6/MigrateI18nBlockContentTest.php +++ b/core/modules/content_translation/tests/src/Kernel/Migrate/d6/MigrateI18nBlockContentTest.php @@ -2,24 +2,22 @@ namespace Drupal\Tests\content_translation\Kernel\Migrate\d6; -use Drupal\block_content\Entity\BlockContent; -use Drupal\language\Entity\ConfigurableLanguage; use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase; /** - * Tests migration of i18n custom block strings. + * Tests migration of i18n block translations. * * @group migrate_drupal_6 */ -class MigrateI18nBlockContentTest extends MigrateDrupal6TestBase { +class MigrateI18nBlockTest extends MigrateDrupal6TestBase { /** * {@inheritdoc} */ public static $modules = [ 'block', + 'views', 'block_content', - 'config_translation', 'content_translation', 'language', ]; @@ -29,46 +27,28 @@ */ protected function setUp() { parent::setUp(); + $this->installConfig(['block']); $this->installConfig(['block_content']); $this->installEntitySchema('block_content'); - ConfigurableLanguage::createFromLangcode('en')->save(); - ConfigurableLanguage::createFromLangcode('fr')->save(); - ConfigurableLanguage::createFromLangcode('zu')->save(); + $this->executeMigrations([ 'd6_filter_format', 'block_content_type', 'block_content_body_field', 'd6_custom_block', - 'd6_i18n_custom_block', + 'd6_user_role', + 'd6_block', + 'd6_i18n_block', ]); + block_rebuild(); } /** - * Tests the Drupal 6 i18n custom block strings to Drupal 8 migration. + * Tests the migration of block title translation. */ - public function testBlockMigration() { - /** @var BlockContent $block */ - $block = BlockContent::load(1)->getTranslation('fr'); - $this->assertSame('fr - Static Block', $block->label()); - $this->assertTrue(REQUEST_TIME <= $block->getChangedTime() && $block->getChangedTime() <= time()); - $this->assertSame('fr', $block->language()->getId()); - $this->assertSame('

fr - My first custom block body

', $block->body->value); - $this->assertSame('full_html', $block->body->format); - - $block = BlockContent::load(1)->getTranslation('zu'); - $this->assertSame('My block 1', $block->label()); - $this->assertTrue(REQUEST_TIME <= $block->getChangedTime() && $block->getChangedTime() <= time()); - $this->assertSame('zu', $block->language()->getId()); - $this->assertSame('

zu - My first custom block body

', $block->body->value); - $this->assertSame('full_html', $block->body->format); - - $block = BlockContent::load(2)->getTranslation('fr'); - $this->assertSame('Encore un bloc statique', $block->label()); - $this->assertTrue(REQUEST_TIME <= $block->getChangedTime() && $block->getChangedTime() <= time()); - $this->assertSame('fr', $block->language()->getId()); - $this->assertSame('Nom de vocabulaire beaucoup plus long que trente-deux caractères', $block->body->value); - $this->assertSame('full_html', $block->body->format); - + public function testI18nBlock() { + $config = \Drupal::service('language_manager')->getLanguageConfigOverride('zu', 'block.block.user_1'); + $this->assertSame('zu - Test Title 02', $config->get('settings.label')); } } reverted: --- b/core/modules/migrate/src/Plugin/migrate/destination/EntityContentBase.php +++ a/core/modules/migrate/src/Plugin/migrate/destination/EntityContentBase.php @@ -7,7 +7,6 @@ use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Field\FieldTypePluginManagerInterface; -use Drupal\Core\Language\LanguageManagerInterface; use Drupal\Core\TypedData\TranslatableInterface; use Drupal\Core\TypedData\TypedDataInterface; use Drupal\migrate\Plugin\MigrationInterface; @@ -22,13 +21,6 @@ class EntityContentBase extends Entity { /** - * The language manager. - * - * @var \Drupal\Core\Language\LanguageManagerInterface - */ - protected $languageManager; - - /** * Entity manager. * * @var \Drupal\Core\Entity\EntityManagerInterface @@ -57,18 +49,15 @@ * The storage for this entity type. * @param array $bundles * The list of bundles this entity type has. - * @param LanguageManagerInterface $language_manager - * The language manager. * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager * The entity manager service. * @param \Drupal\Core\Field\FieldTypePluginManagerInterface $field_type_manager * The field type plugin manager service. */ + public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EntityStorageInterface $storage, array $bundles, EntityManagerInterface $entity_manager, FieldTypePluginManagerInterface $field_type_manager) { - public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EntityStorageInterface $storage, array $bundles, LanguageManagerInterface $language_manager, EntityManagerInterface $entity_manager, FieldTypePluginManagerInterface $field_type_manager) { parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $storage, $bundles); $this->entityManager = $entity_manager; $this->fieldTypeManager = $field_type_manager; - $this->languageManager = $language_manager; } /** @@ -82,9 +71,7 @@ $plugin_definition, $migration, $container->get('entity.manager')->getStorage($entity_type), + array_keys($container->get('entity.manager')->getBundleInfo($entity_type)), - array_keys($container->get('entity.manager') - ->getBundleInfo($entity_type)), - $container->get('language_manager'), $container->get('entity.manager'), $container->get('plugin.manager.field.field_type') ); @@ -93,7 +80,7 @@ /** * {@inheritdoc} */ + public function import(Row $row, array $old_destination_id_values = array()) { - public function import(Row $row, array $old_destination_id_values = []) { $this->rollbackAction = MigrateIdMapInterface::ROLLBACK_DELETE; $entity = $this->getEntity($row, $old_destination_id_values); if (!$entity) { @@ -118,9 +105,9 @@ * @return array * An array containing the entity ID. */ + protected function save(ContentEntityInterface $entity, array $old_destination_id_values = array()) { - protected function save(ContentEntityInterface $entity, array $old_destination_id_values = []) { $entity->save(); + return array($entity->id()); - return [$entity->id()]; } /** @@ -298,8 +285,8 @@ $field_definition = $definitions[$key]; return [ + 'type' => $field_definition->getType(), + ] + $field_definition->getSettings(); - 'type' => $field_definition->getType(), - ] + $field_definition->getSettings(); } } reverted: --- b/core/modules/migrate/tests/src/Kernel/MigrateEntityContentBaseTest.php +++ a/core/modules/migrate/tests/src/Kernel/MigrateEntityContentBaseTest.php @@ -86,7 +86,6 @@ $this->getMock(MigrationInterface::class), $this->storage, [], - $this->container->get('language_manager'), $this->container->get('entity.manager'), $this->container->get('plugin.manager.field.field_type') ); reverted: --- b/core/modules/migrate/tests/src/Unit/Plugin/migrate/destination/EntityContentBaseTest.php +++ a/core/modules/migrate/tests/src/Unit/Plugin/migrate/destination/EntityContentBaseTest.php @@ -13,7 +13,6 @@ use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Field\BaseFieldDefinition; use Drupal\Core\Field\FieldTypePluginManagerInterface; -use Drupal\Core\Language\LanguageManagerInterface; use Drupal\migrate\Plugin\MigrationInterface; use Drupal\migrate\Plugin\migrate\destination\EntityContentBase; use Drupal\migrate\Plugin\MigrateIdMapInterface; @@ -44,13 +43,6 @@ protected $entityManager; /** - * The language manager. - * - * @var \Drupal\Core\Language\LanguageManagerInterface - */ - protected $languageManager; - - /** * {@inheritdoc} */ protected function setUp() { @@ -59,7 +51,6 @@ $this->migration = $this->prophesize(MigrationInterface::class); $this->storage = $this->prophesize(EntityStorageInterface::class); $this->entityManager = $this->prophesize(EntityManagerInterface::class); - $this->languageManager = $this->prophesize(LanguageManagerInterface::class); } /** @@ -73,7 +64,6 @@ $this->migration->reveal(), $this->storage->reveal(), $bundles, - $this->languageManager->reveal(), $this->entityManager->reveal(), $this->prophesize(FieldTypePluginManagerInterface::class)->reveal()); $entity = $this->prophesize(ContentEntityInterface::class); @@ -103,7 +93,6 @@ $this->migration->reveal(), $this->storage->reveal(), $bundles, - $this->languageManager->reveal(), $this->entityManager->reveal(), $this->prophesize(FieldTypePluginManagerInterface::class)->reveal()); $destination->setEntity(FALSE); @@ -133,7 +122,6 @@ $this->migration->reveal(), $this->storage->reveal(), [], - $this->languageManager->reveal(), $this->entityManager->reveal(), $this->prophesize(FieldTypePluginManagerInterface::class)->reveal() ); reverted: --- b/core/modules/migrate/tests/src/Unit/destination/EntityRevisionTest.php +++ a/core/modules/migrate/tests/src/Unit/destination/EntityRevisionTest.php @@ -9,7 +9,6 @@ use Drupal\Core\Entity\ContentEntityInterface; use Drupal\Core\Entity\EntityInterface; -use Drupal\Core\Language\LanguageManagerInterface; use Drupal\migrate\Plugin\MigrationInterface; use Drupal\migrate\Plugin\migrate\destination\EntityRevision as RealEntityRevision; use Drupal\migrate\Row; @@ -43,13 +42,6 @@ */ protected $fieldTypeManager; - /** - * The language manager. - * - * @var \Drupal\Core\Language\LanguageManagerInterface - */ - protected $languageManager; - protected function setUp() { parent::setUp(); @@ -58,8 +50,6 @@ $this->storage = $this->prophesize('\Drupal\Core\Entity\EntityStorageInterface'); $this->entityManager = $this->prophesize('\Drupal\Core\Entity\EntityManagerInterface'); $this->fieldTypeManager = $this->prophesize('\Drupal\Core\Field\FieldTypePluginManagerInterface'); - $this->languageManager = $this->prophesize(LanguageManagerInterface::class); - } /** @@ -200,7 +190,6 @@ $this->migration->reveal(), $this->storage->reveal(), [], - $this->languageManager->reveal(), $this->entityManager->reveal(), $this->fieldTypeManager->reveal() ); reverted: --- b/core/modules/migrate_drupal/src/Plugin/migrate/destination/EntityFieldStorageConfig.php +++ a/core/modules/migrate_drupal/src/Plugin/migrate/destination/EntityFieldStorageConfig.php @@ -26,13 +26,6 @@ class EntityFieldStorageConfig extends BaseEntityFieldStorageConfig { /** - * The language manager. - * - * @var \Drupal\Core\Language\LanguageManagerInterface - */ - protected $languageManager; - - /** * The field type plugin manager. * * @var \Drupal\Core\Field\FieldTypePluginManagerInterface diff -u b/core/modules/migrate_drupal_ui/src/Form/MigrateUpgradeForm.php b/core/modules/migrate_drupal_ui/src/Form/MigrateUpgradeForm.php --- b/core/modules/migrate_drupal_ui/src/Form/MigrateUpgradeForm.php +++ b/core/modules/migrate_drupal_ui/src/Form/MigrateUpgradeForm.php @@ -67,8 +67,8 @@ 'destination_module' => 'block', ], 'd6_i18n_block' => [ - 'source_module' => 'translation', - 'destination_module' => 'config_translation', + 'source_module' => 'i18n', + 'destination_module' => 'content_translation', ], 'd7_block' => [ 'source_module' => 'block', reverted: --- b/core/modules/user/src/Plugin/migrate/destination/EntityUser.php +++ a/core/modules/user/src/Plugin/migrate/destination/EntityUser.php @@ -8,7 +8,6 @@ use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Field\FieldTypePluginManagerInterface; use Drupal\Core\Field\Plugin\Field\FieldType\EmailItem; -use Drupal\Core\language\LanguageManagerInterface; use Drupal\Core\Password\PasswordInterface; use Drupal\migrate\Plugin\MigrationInterface; use Drupal\migrate\Plugin\migrate\destination\EntityContentBase; @@ -44,8 +43,6 @@ * The storage for this entity type. * @param array $bundles * The list of bundles this entity type has. - * @param \Drupal\Core\language\LanguageManagerInterface $language_manager - * The language manager service. * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager * The entity manager service. * @param \Drupal\Core\Field\FieldTypePluginManagerInterface $field_type_manager @@ -53,8 +50,8 @@ * @param \Drupal\Core\Password\PasswordInterface $password * The password service. */ + public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EntityStorageInterface $storage, array $bundles, EntityManagerInterface $entity_manager, FieldTypePluginManagerInterface $field_type_manager, PasswordInterface $password) { + parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $storage, $bundles, $entity_manager, $field_type_manager); - public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EntityStorageInterface $storage, array $bundles, LanguageManagerInterface $language_manager, EntityManagerInterface $entity_manager, FieldTypePluginManagerInterface $field_type_manager, PasswordInterface $password) { - parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $storage, $bundles, $language_manager, $entity_manager, $field_type_manager); $this->password = $password; } @@ -70,7 +67,6 @@ $migration, $container->get('entity.manager')->getStorage($entity_type), array_keys($container->get('entity.manager')->getBundleInfo($entity_type)), - $container->get('language_manager'), $container->get('entity.manager'), $container->get('plugin.manager.field.field_type'), $container->get('password') only in patch2: unchanged: --- /dev/null +++ b/core/modules/content_translation/migration_templates/d6_i18n_block.yml @@ -0,0 +1,71 @@ +id: d6_i18n_block +label: i18n Blocks +migration_tags: + - Drupal 6 +source: + plugin: d6_i18n_block + constants: + dest_label: 'settings/label' +process: + langcode: language + property: constants/dest_label + translation: title + id: + - + plugin: concat + source: + - module + - delta + delimiter: _ + - + plugin: substr + length: 32 + configuration_name: @id + element_name: constance/dest_label + value: title + 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 only in patch2: unchanged: --- /dev/null +++ b/core/modules/content_translation/src/Plugin/migrate/source/d6/I18nBlock.php @@ -0,0 +1,104 @@ +getModuleSchemaVersion('system') >= 7000) { + $this->blockTable = 'block'; + } + else { + $this->blockTable = 'blocks'; + } + + $query = $this->select('i18n_blocks', 'i18n') + ->fields('i18n', ['ibid', 'module', 'delta', 'type', 'language']) + ->fields('b', ['bid', 'module', 'delta', 'theme', 'title']); + $query->addField('b', 'module', 'block_module'); + $query->addField('b', 'delta', 'block_delta'); + $query->leftJoin($this->blockTable, 'b', ('b.module = i18n.module AND b.delta = i18n.delta')); + return $query; + } + + /** + * {@inheritdoc} + */ + protected function initializeIterator() { + $this->defaultTheme = $this->variableGet('theme_default', 'Garland'); + $this->adminTheme = $this->variableGet('admin_theme', NULL); + return parent::initializeIterator(); + } + + /** + * {@inheritdoc} + */ + public function fields() { + return [ + 'bid' => $this->t('The block numeric identifier.'), + 'module' => $this->t('The module providing the block.'), + 'delta' => $this->t("The block's delta."), + 'title' => $this->t("Title translation for this language.."), + 'theme' => $this->t('Which theme the block is placed in.'), + 'language' => $this->t('Language for this field.'), + ]; + } + + /** + * {@inheritdoc} + */ + public function getIds() { + $ids['module']['type'] = 'string'; + $ids['module']['alias'] = 'b'; + $ids['delta']['type'] = 'string'; + $ids['delta']['alias'] = 'b'; + $ids['theme']['type'] = 'string'; + $ids['language']['type'] = 'string'; + return $ids; + } + + /** + * {@inheritdoc} + */ + public function prepareRow(Row $row) { + $row->setSourceProperty('default_theme', $this->defaultTheme); + $row->setSourceProperty('admin_theme', $this->adminTheme); + return parent::prepareRow($row); + } + +} only in patch2: unchanged: --- /dev/null +++ b/core/modules/content_translation/tests/src/Kernel/Migrate/d6/MigrateI18nCustomBlockContentTest.php @@ -0,0 +1,73 @@ +installConfig(['block_content']); + $this->installEntitySchema('block_content'); + ConfigurableLanguage::createFromLangcode('en')->save(); + ConfigurableLanguage::createFromLangcode('fr')->save(); + ConfigurableLanguage::createFromLangcode('zu')->save(); + $this->executeMigrations([ + 'd6_filter_format', + 'block_content_type', + 'block_content_body_field', + 'd6_custom_block', + 'd6_i18n_custom_block', + ]); + } + + /** + * Tests the Drupal 6 i18n custom block strings to Drupal 8 migration. + */ + public function testBlockMigration() { + /** @var BlockContent $block */ + $block = BlockContent::load(1)->getTranslation('fr'); + $this->assertSame('fr - Static Block', $block->label()); + $this->assertTrue(REQUEST_TIME <= $block->getChangedTime() && $block->getChangedTime() <= time()); + $this->assertSame('fr', $block->language()->getId()); + $this->assertSame('

fr - My first custom block body

', $block->body->value); + $this->assertSame('full_html', $block->body->format); + + $block = BlockContent::load(1)->getTranslation('zu'); + $this->assertSame('My block 1', $block->label()); + $this->assertTrue(REQUEST_TIME <= $block->getChangedTime() && $block->getChangedTime() <= time()); + $this->assertSame('zu', $block->language()->getId()); + $this->assertSame('

zu - My first custom block body

', $block->body->value); + $this->assertSame('full_html', $block->body->format); + + $block = BlockContent::load(2)->getTranslation('fr'); + $this->assertSame('Encore un bloc statique', $block->label()); + $this->assertTrue(REQUEST_TIME <= $block->getChangedTime() && $block->getChangedTime() <= time()); + $this->assertSame('fr', $block->language()->getId()); + $this->assertSame('Nom de vocabulaire beaucoup plus long que trente-deux caractères', $block->body->value); + $this->assertSame('full_html', $block->body->format); + } + +} only in patch2: unchanged: --- /dev/null +++ b/core/modules/content_translation/tests/src/Kernel/Plugin/migrate/source/d6/I18nBlockTest.php @@ -0,0 +1,100 @@ + 1, + 'module' => 'user', + 'delta' => '1', + 'theme' => 'garland', + 'status' => 1, + 'weight' => 0, + 'region' => 'left', + 'visibility' => 0, + 'pages' => '', + 'title' => 'fr - Test Title 01', + 'cache' => -1, + ], + [ + 'bid' => 2, + 'module' => 'user', + 'delta' => '2', + 'theme' => 'garland', + 'status' => 1, + 'weight' => 5, + 'region' => 'right', + 'visibility' => 0, + 'pages' => '', + 'title' => 'zu - Test Title 02', + 'cache' => -1, + ], + ]; + + $tests[0]['source_data']['i18n_blocks'] = [ + [ + 'ibid' => 1, + 'module' => 'user', + 'delta' => '1', + 'type' => 0, + 'language' => 'fr', + ], + [ + 'ibid' => 2, + 'module' => 'user', + 'delta' => '2', + 'type' => 0, + 'language' => 'zu', + ], + ]; + + // The expected results. + $tests[0]['expected_results'] = [ + [ + 'bid' => 1, + 'module' => 'user', + 'delta' => '1', + 'title' => 'fr - Test Title 01', + 'ibid' => 1, + 'type' => '0', + 'language' => 'fr', + ], + [ + 'bid' => 2, + 'module' => 'user', + 'delta' => '2', + 'theme' => 'garland', + 'title' => 'zu - Test Title 02', + 'ibid' => 2, + 'type' => '0', + 'language' => 'zu', + ], + ]; + + return $tests; + } + +} only in patch2: unchanged: --- a/core/modules/migrate_drupal/tests/fixtures/drupal6.php +++ b/core/modules/migrate_drupal/tests/fixtures/drupal6.php @@ -662,7 +662,7 @@ 'throttle' => '0', 'visibility' => '0', 'pages' => '', - 'title' => '', + 'title' => 'zu - Test Title 02', 'cache' => '-1', )) ->values(array( @@ -8086,6 +8086,23 @@ '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', +)) +->execute(); + $connection->schema()->createTable('i18n_strings', array( 'fields' => array( 'lid' => array(