Revert "Issue #2225587 by quietone, Jo Fitzgerald, heddn, Pavan B S, maxocub, phenaproxima, Gábor Hojtsy, ao2, alexpott: Migrate D6 i18n menu links"
This reverts commit 66480d7f40
.
merge-requests/1654/head
parent
d25a77e0ec
commit
b61e2a65fc
|
@ -1,21 +0,0 @@
|
|||
id: d6_language_content_menu_settings
|
||||
label: Drupal 6 language content menu settings
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
- Configuration
|
||||
source:
|
||||
plugin: extension
|
||||
name: i18nmenu
|
||||
constants:
|
||||
target_type: 'menu_link_content'
|
||||
langcode: 'site_default'
|
||||
process:
|
||||
target_entity_type_id: 'constants/target_type'
|
||||
# menu_link_content has a bundle key but no bundle support so use the entity
|
||||
# type as the bundle.
|
||||
target_bundle: 'constants/target_type'
|
||||
default_langcode: 'constants/langcode'
|
||||
# Drupal 6 menus are translated when the i18nmenu module is enabled.
|
||||
language_alterable: status
|
||||
destination:
|
||||
plugin: entity:language_content_settings
|
|
@ -1,68 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\language\Kernel\Migrate\d6;
|
||||
|
||||
use Drupal\language\Entity\ConfigurableLanguage;
|
||||
use Drupal\language\Entity\ContentLanguageSettings;
|
||||
use Drupal\Core\Language\LanguageInterface;
|
||||
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
|
||||
|
||||
/**
|
||||
* Tests migration of the ability to translate menu content.
|
||||
*
|
||||
* @group migrate_drupal_6
|
||||
*/
|
||||
class MigrateLanguageContentMenuSettingsTest extends MigrateDrupal6TestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = [
|
||||
'language',
|
||||
'content_translation',
|
||||
'menu_link_content',
|
||||
];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
// Create some languages.
|
||||
ConfigurableLanguage::createFromLangcode('en')->save();
|
||||
ConfigurableLanguage::createFromLangcode('fr')->save();
|
||||
$this->executeMigrations(['d6_language_content_menu_settings']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests migration of menu translation ability.
|
||||
*/
|
||||
public function testLanguageMenuContent() {
|
||||
$config = ContentLanguageSettings::load('menu_link_content.menu_link_content');
|
||||
$this->assertInstanceOf(ContentLanguageSettings::class, $config);
|
||||
$this->assertSame('menu_link_content', $config->getTargetEntityTypeId());
|
||||
$this->assertSame('menu_link_content', $config->getTargetBundle());
|
||||
$this->assertSame(LanguageInterface::LANGCODE_SITE_DEFAULT, $config->getDefaultLangcode());
|
||||
$this->assertTrue($config->isLanguageAlterable());
|
||||
|
||||
// Test that menus are not alterable when the i18nmenu is not enabled.
|
||||
$this->sourceDatabase->update('system')
|
||||
->fields(['status' => 0])
|
||||
->condition('name', 'i18nmenu')
|
||||
->execute();
|
||||
|
||||
/** @var \Drupal\migrate\Plugin\MigrationInterface $migration */
|
||||
$migration = $this->getMigration('d6_language_content_menu_settings');
|
||||
// Indicate we're rerunning a migration that's already run.
|
||||
$migration->getIdMap()->prepareUpdate();
|
||||
$this->executeMigration($migration);
|
||||
|
||||
$config = ContentLanguageSettings::load('menu_link_content.menu_link_content');
|
||||
$this->assertInstanceOf(ContentLanguageSettings::class, $config);
|
||||
$this->assertSame('menu_link_content', $config->getTargetEntityTypeId());
|
||||
$this->assertSame('menu_link_content', $config->getTargetBundle());
|
||||
$this->assertSame(LanguageInterface::LANGCODE_SITE_DEFAULT, $config->getDefaultLangcode());
|
||||
$this->assertFalse($config->isLanguageAlterable());
|
||||
}
|
||||
|
||||
}
|
|
@ -1,54 +0,0 @@
|
|||
id: d6_menu_links_translation
|
||||
label: Menu links
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
- Content
|
||||
source:
|
||||
plugin: d6_menu_link_translation
|
||||
process:
|
||||
id: mlid
|
||||
langcode: language
|
||||
title:
|
||||
-
|
||||
plugin: callback
|
||||
source:
|
||||
- title_translated
|
||||
- link_title
|
||||
callable: array_filter
|
||||
-
|
||||
plugin: callback
|
||||
callable: current
|
||||
description:
|
||||
-
|
||||
plugin: callback
|
||||
source:
|
||||
- description_translated
|
||||
- description
|
||||
callable: array_filter
|
||||
-
|
||||
plugin: callback
|
||||
callable: current
|
||||
menu_name:
|
||||
-
|
||||
plugin: migration_lookup
|
||||
# The menu migration is in the system module.
|
||||
migration: d6_menu
|
||||
source: menu_name
|
||||
-
|
||||
plugin: skip_on_empty
|
||||
method: row
|
||||
-
|
||||
plugin: static_map
|
||||
map:
|
||||
management: admin
|
||||
bypass: true
|
||||
destination:
|
||||
plugin: entity:menu_link_content
|
||||
default_bundle: menu_link_content
|
||||
no_stub: true
|
||||
translations: true
|
||||
migration_dependencies:
|
||||
required:
|
||||
- language
|
||||
- d6_menu
|
||||
- d6_menu_links
|
|
@ -1,97 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\menu_link_content\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\migrate\Row;
|
||||
use Drupal\menu_link_content\Plugin\migrate\source\MenuLink;
|
||||
|
||||
/**
|
||||
* Gets Menu link translations from source database.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d6_menu_link_translation",
|
||||
* source_module = "i18nmenu"
|
||||
* )
|
||||
*/
|
||||
class MenuLinkTranslation extends MenuLink {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
// Ideally, the query would return rows for each language for each menu link
|
||||
// with the translations for both the title and description or just the
|
||||
// title translation or just the description translation. That query quickly
|
||||
// became complex and would be difficult to maintain.
|
||||
// Therefore, build a query based on i18nstrings table where each row has
|
||||
// the translation for only one property, either title or description. The
|
||||
// method prepareRow() is then used to obtain the translation for the other
|
||||
// property.
|
||||
// The query starts with the same query as menu_link.
|
||||
$query = parent::query();
|
||||
|
||||
// Add in the property, which is either title or description.
|
||||
$query->leftJoin('i18n_strings', 'i18n', 'ml.mlid = i18n.objectid');
|
||||
$query->isNotNull('i18n.lid');
|
||||
$query->addField('i18n', 'lid');
|
||||
$query->addField('i18n', 'property');
|
||||
|
||||
// Add in the translation for the property.
|
||||
$query->innerJoin('locales_target', 'lt', 'i18n.lid = lt.lid');
|
||||
$query->addField('lt', 'language');
|
||||
$query->addField('lt', 'translation');
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function prepareRow(Row $row) {
|
||||
$language = $row->getSourceProperty('language');
|
||||
$mlid = $row->getSourceProperty('mlid');
|
||||
|
||||
// If this row has been migrated it is a duplicate then skip it.
|
||||
if ($this->idMap->lookupDestinationIds(['mlid' => $mlid, 'language' => $language])) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Save the translation for this property.
|
||||
$property = $row->getSourceProperty('property');
|
||||
$row->setSourceProperty($property . '_translated', $row->getSourceProperty('translation'));
|
||||
|
||||
// Get the translation, if one exists, for the property not already in the
|
||||
// row.
|
||||
$other_property = ($property == 'title') ? 'description' : 'title';
|
||||
$query = $this->select('i18n_strings', 'i18n')
|
||||
->fields('i18n', ['lid'])
|
||||
->condition('i18n.property', $other_property)
|
||||
->condition('i18n.objectid', $mlid);
|
||||
$query->leftJoin('locales_target', 'lt', 'i18n.lid = lt.lid');
|
||||
$query->condition('lt.language', $language);
|
||||
$query->addField('lt', 'translation');
|
||||
$results = $query->execute()->fetchAssoc();
|
||||
$row->setSourceProperty($other_property . '_translated', $results['translation']);
|
||||
parent::prepareRow($row);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
$fields = [
|
||||
'language' => $this->t('Language for this menu.'),
|
||||
'title_translated' => $this->t('Menu link title translation.'),
|
||||
'description_translated' => $this->t('Menu link description translation.'),
|
||||
];
|
||||
return parent::fields() + $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['language']['type'] = 'string';
|
||||
return parent::getIds() + $ids;
|
||||
}
|
||||
|
||||
}
|
|
@ -84,7 +84,7 @@ class MigrateMenuLinkTest extends MigrateNodeTestBase {
|
|||
* Tests migration of menu links.
|
||||
*/
|
||||
public function testMenuLinks() {
|
||||
$this->assertEntity('138', 'Test 1', 'secondary-links', 'Test menu link 1', TRUE, FALSE, ['attributes' => ['title' => 'Test menu link 1'], 'langcode' => 'en'], 'internal:/user/login', -50);
|
||||
$this->assertEntity('138', 'Test 1', 'secondary-links', 'Test menu link 1', TRUE, FALSE, ['attributes' => ['title' => 'Test menu link 1']], 'internal:/user/login', -50);
|
||||
$this->assertEntity('139', 'Test 2', 'secondary-links', 'Test menu link 2', TRUE, TRUE, ['query' => 'foo=bar', 'attributes' => ['title' => 'Test menu link 2']], 'internal:/admin', -49);
|
||||
$this->assertEntity('140', 'Drupal.org', 'secondary-links', NULL, TRUE, FALSE, ['attributes' => ['title' => '']], 'https://www.drupal.org', -50);
|
||||
|
||||
|
@ -96,9 +96,6 @@ class MigrateMenuLinkTest extends MigrateNodeTestBase {
|
|||
$this->assertEntity('460', 'Le Vrai McCoy', 'primary-links', NULL, TRUE, FALSE, ['attributes' => ['title' => ''], 'alter' => TRUE], 'entity:node/10', 0);
|
||||
$this->assertEntity('461', 'Abantu zulu', 'primary-links', NULL, TRUE, FALSE, ['attributes' => ['title' => ''], 'alter' => TRUE], 'entity:node/12', 0);
|
||||
$this->assertEntity('462', 'The Zulu People', 'primary-links', NULL, TRUE, FALSE, ['attributes' => ['title' => ''], 'alter' => TRUE], 'entity:node/12', 0);
|
||||
|
||||
// Test the migration of menu links translation.
|
||||
$this->assertEntity('463', 'fr - Test 1', 'secondary-links', 'fr - Test menu link 1', TRUE, FALSE, ['attributes' => ['title' => 'fr - Test menu link 1'], 'langcode' => 'fr', 'alter' => TRUE], 'internal:/user/login', -49);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,93 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\menu_link_content\Kernel\Migrate\d6;
|
||||
|
||||
use Drupal\menu_link_content\Entity\MenuLinkContent;
|
||||
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
|
||||
|
||||
/**
|
||||
* Menu link migration.
|
||||
*
|
||||
* @group migrate_drupal_6
|
||||
*/
|
||||
class MigrateMenuLinkTranslationTest extends MigrateDrupal6TestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['menu_ui', 'menu_link_content', 'language'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->migrateContent();
|
||||
$this->installSchema('system', ['router']);
|
||||
$this->installEntitySchema('menu_link_content');
|
||||
$this->executeMigrations([
|
||||
'language',
|
||||
'd6_menu',
|
||||
'd6_menu_links',
|
||||
'd6_menu_links_translation',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests migration of menu links.
|
||||
*/
|
||||
public function testMenuLinks() {
|
||||
/** @var \Drupal\menu_link_content\Entity\MenuLinkContent $menu_link */
|
||||
$menu_link = MenuLinkContent::load(139)->getTranslation('fr');
|
||||
$this->assertInstanceOf(MenuLinkContent::class, $menu_link);
|
||||
$this->assertSame('fr - Test 2', $menu_link->getTitle());
|
||||
$this->assertSame('fr - Test menu link 2', $menu_link->getDescription());
|
||||
$this->assertSame('secondary-links', $menu_link->getMenuName());
|
||||
$this->assertTrue($menu_link->isEnabled());
|
||||
$this->assertTrue($menu_link->isExpanded());
|
||||
$this->assertSame(['query' => 'foo=bar', 'attributes' => ['title' => 'Test menu link 2']], $menu_link->link->options);
|
||||
$this->assertSame('internal:/admin', $menu_link->link->uri);
|
||||
$this->assertSame(-49, $menu_link->getWeight());
|
||||
|
||||
$menu_link = MenuLinkContent::load(139)->getTranslation('zu');
|
||||
$this->assertInstanceOf(MenuLinkContent::class, $menu_link);
|
||||
$this->assertSame('Test 2', $menu_link->getTitle());
|
||||
$this->assertSame('zu - Test menu link 2', $menu_link->getDescription());
|
||||
$this->assertSame('secondary-links', $menu_link->getMenuName());
|
||||
$this->assertTrue($menu_link->isEnabled());
|
||||
$this->assertTrue($menu_link->isExpanded());
|
||||
$this->assertSame(['query' => 'foo=bar', 'attributes' => ['title' => 'Test menu link 2']], $menu_link->link->options);
|
||||
$this->assertSame('internal:/admin', $menu_link->link->uri);
|
||||
$this->assertSame(-49, $menu_link->getWeight());
|
||||
|
||||
$menu_link = MenuLinkContent::load(140)->getTranslation('fr');
|
||||
$this->assertInstanceOf(MenuLinkContent::class, $menu_link);
|
||||
$this->assertSame('fr - Drupal.org', $menu_link->getTitle());
|
||||
$this->assertSame('', $menu_link->getDescription());
|
||||
$this->assertSame('secondary-links', $menu_link->getMenuName());
|
||||
$this->assertTrue($menu_link->isEnabled());
|
||||
$this->assertFalse($menu_link->isExpanded());
|
||||
$this->assertSame(['attributes' => ['title' => '']], $menu_link->link->options);
|
||||
$this->assertSame('https://www.drupal.org', $menu_link->link->uri);
|
||||
$this->assertSame(-50, $menu_link->getWeight());
|
||||
|
||||
$menu_link = MenuLinkContent::load(463);
|
||||
$this->assertInstanceOf(MenuLinkContent::class, $menu_link);
|
||||
$this->assertSame('fr - Test 1', $menu_link->getTitle());
|
||||
$this->assertSame('fr - Test menu link 1', $menu_link->getDescription());
|
||||
$this->assertSame('secondary-links', $menu_link->getMenuName());
|
||||
$this->assertTrue($menu_link->isEnabled());
|
||||
$this->assertFalse($menu_link->isExpanded());
|
||||
$attributes = [
|
||||
'attributes' => [
|
||||
'title' => 'fr - Test menu link 1',
|
||||
],
|
||||
'langcode' => 'fr',
|
||||
'alter' => TRUE,
|
||||
];
|
||||
$this->assertSame($attributes, $menu_link->link->options);
|
||||
$this->assertSame('internal:/user/login', $menu_link->link->uri);
|
||||
$this->assertSame(-49, $menu_link->getWeight());
|
||||
}
|
||||
|
||||
}
|
|
@ -1,250 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\menu_link_content\Kernel\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
|
||||
|
||||
/**
|
||||
* Tests menu link translation source plugin.
|
||||
*
|
||||
* @covers \Drupal\menu_link_content\Plugin\migrate\source\d6\MenuLinkTranslation
|
||||
* @group menu_link_content
|
||||
*/
|
||||
class MenuLinkTranslationTest extends MigrateSqlSourceTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['menu_link_content', 'migrate_drupal'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function providerSource() {
|
||||
$test = [];
|
||||
$test[0]['source_data']['menu_links'] = [
|
||||
[
|
||||
'menu_name' => 'menu-test-menu',
|
||||
'mlid' => 138,
|
||||
'plid' => 0,
|
||||
'link_path' => 'admin',
|
||||
'router_path' => 'admin',
|
||||
'link_title' => 'Test 1',
|
||||
'options' => 'a:1:{s:10:"attributes";a:1:{s:5:"title";s:16:"Test menu link 1";}}',
|
||||
'module' => 'menu',
|
||||
'hidden' => 0,
|
||||
'external' => 0,
|
||||
'has_children' => 1,
|
||||
'expanded' => 0,
|
||||
'weight' => 15,
|
||||
'depth' => 1,
|
||||
'customized' => 1,
|
||||
'p1' => '138',
|
||||
'p2' => '0',
|
||||
'p3' => '0',
|
||||
'p4' => '0',
|
||||
'p5' => '0',
|
||||
'p6' => '0',
|
||||
'p7' => '0',
|
||||
'p8' => '0',
|
||||
'p9' => '0',
|
||||
'updated' => '0',
|
||||
],
|
||||
[
|
||||
'menu_name' => 'menu-test-menu',
|
||||
'mlid' => 139,
|
||||
'plid' => 138,
|
||||
'link_path' => 'admin/modules',
|
||||
'router_path' => 'admin/modules',
|
||||
'link_title' => 'Test 2',
|
||||
'options' => 'a:1:{s:10:"attributes";a:1:{s:5:"title";s:16:"Test menu link 2";}}',
|
||||
'module' => 'menu',
|
||||
'hidden' => 0,
|
||||
'external' => 0,
|
||||
'has_children' => 0,
|
||||
'expanded' => 0,
|
||||
'weight' => 12,
|
||||
'depth' => 2,
|
||||
'customized' => 1,
|
||||
'p1' => '138',
|
||||
'p2' => '139',
|
||||
'p3' => '0',
|
||||
'p4' => '0',
|
||||
'p5' => '0',
|
||||
'p6' => '0',
|
||||
'p7' => '0',
|
||||
'p8' => '0',
|
||||
'p9' => '0',
|
||||
'updated' => '0',
|
||||
],
|
||||
[
|
||||
'menu_name' => 'menu-test-menu',
|
||||
'mlid' => 140,
|
||||
'plid' => 0,
|
||||
'link_path' => 'https://www.drupal.org',
|
||||
'router_path' => 'admin/modules',
|
||||
'link_title' => 'Test 2',
|
||||
'options' => 'a:1:{s:10:"attributes";a:1:{s:5:"title";s:16:"Test menu link 2";}}',
|
||||
'module' => 'menu',
|
||||
'hidden' => 0,
|
||||
'external' => 0,
|
||||
'has_children' => 0,
|
||||
'expanded' => 0,
|
||||
'weight' => 12,
|
||||
'depth' => 2,
|
||||
'customized' => 1,
|
||||
'p1' => '0',
|
||||
'p2' => '0',
|
||||
'p3' => '0',
|
||||
'p4' => '0',
|
||||
'p5' => '0',
|
||||
'p6' => '0',
|
||||
'p7' => '0',
|
||||
'p8' => '0',
|
||||
'p9' => '0',
|
||||
'updated' => '0',
|
||||
],
|
||||
[
|
||||
'menu_name' => 'menu-test-menu',
|
||||
'mlid' => 141,
|
||||
'plid' => 0,
|
||||
'link_path' => 'https://api.drupal.org/api/drupal/8.3.x',
|
||||
'router_path' => 'admin/modules',
|
||||
'link_title' => 'Test 3',
|
||||
'options' => 'a:1:{s:10:"attributes";a:1:{s:5:"title";s:16:"Test menu link 3";}}',
|
||||
'module' => 'menu',
|
||||
'hidden' => 0,
|
||||
'external' => 0,
|
||||
'has_children' => 0,
|
||||
'expanded' => 0,
|
||||
'weight' => 12,
|
||||
'depth' => 2,
|
||||
'customized' => 1,
|
||||
'p1' => '0',
|
||||
'p2' => '0',
|
||||
'p3' => '0',
|
||||
'p4' => '0',
|
||||
'p5' => '0',
|
||||
'p6' => '0',
|
||||
'p7' => '0',
|
||||
'p8' => '0',
|
||||
'p9' => '0',
|
||||
'updated' => '0',
|
||||
],
|
||||
];
|
||||
$test[0]['source_data']['i18n_strings'] = [
|
||||
[
|
||||
'lid' => 1,
|
||||
'objectid' => 139,
|
||||
'type' => 'item',
|
||||
'property' => 'title',
|
||||
'objectindex' => 0,
|
||||
'format' => 0,
|
||||
],
|
||||
[
|
||||
'lid' => 2,
|
||||
'objectid' => 139,
|
||||
'type' => 'item',
|
||||
'property' => 'description',
|
||||
'objectindex' => 0,
|
||||
'format' => 0,
|
||||
],
|
||||
[
|
||||
'lid' => 3,
|
||||
'objectid' => 140,
|
||||
'type' => 'item',
|
||||
'property' => 'description',
|
||||
'objectindex' => 0,
|
||||
'format' => 0,
|
||||
],
|
||||
[
|
||||
'lid' => 4,
|
||||
'objectid' => 141,
|
||||
'type' => 'item',
|
||||
'property' => 'title',
|
||||
'objectindex' => 0,
|
||||
'format' => 0,
|
||||
],
|
||||
];
|
||||
$test[0]['source_data']['locales_target'] = [
|
||||
[
|
||||
'lid' => 1,
|
||||
'language' => 'fr',
|
||||
'translation' => 'fr - title translation',
|
||||
'plid' => 0,
|
||||
'plural' => 0,
|
||||
'i18n_status' => 0,
|
||||
],
|
||||
[
|
||||
'lid' => 2,
|
||||
'language' => 'fr',
|
||||
'translation' => 'fr - description translation',
|
||||
'plid' => 0,
|
||||
'plural' => 0,
|
||||
'i18n_status' => 0,
|
||||
],
|
||||
[
|
||||
'lid' => 3,
|
||||
'language' => 'zu',
|
||||
'translation' => 'zu - description translation',
|
||||
'plid' => 0,
|
||||
'plural' => 0,
|
||||
'i18n_status' => 0,
|
||||
],
|
||||
[
|
||||
'lid' => 4,
|
||||
'language' => 'zu',
|
||||
'translation' => 'zu - title translation',
|
||||
'plid' => 0,
|
||||
'plural' => 0,
|
||||
'i18n_status' => 0,
|
||||
],
|
||||
];
|
||||
|
||||
$test[0]['expected_results'] = [
|
||||
[
|
||||
'menu_name' => 'menu-test-menu',
|
||||
'mlid' => 139,
|
||||
'property' => 'title',
|
||||
'language' => 'fr',
|
||||
'link_title' => 'Test 2',
|
||||
'description' => 'Test menu link 2',
|
||||
'title_translated' => 'fr - title translation',
|
||||
'description_translated' => 'fr - description translation',
|
||||
],
|
||||
[
|
||||
'menu_name' => 'menu-test-menu',
|
||||
'mlid' => 139,
|
||||
'property' => 'description',
|
||||
'language' => 'fr',
|
||||
'link_title' => 'Test 2',
|
||||
'description' => 'Test menu link 2',
|
||||
'title_translated' => 'fr - title translation',
|
||||
'description_translated' => 'fr - description translation',
|
||||
],
|
||||
[
|
||||
'menu_name' => 'menu-test-menu',
|
||||
'mlid' => 140,
|
||||
'property' => 'description',
|
||||
'language' => 'zu',
|
||||
'link_title' => 'Test 2',
|
||||
'description' => 'Test menu link 2',
|
||||
'title_translated' => NULL,
|
||||
'description_translated' => 'zu - description translation',
|
||||
],
|
||||
[
|
||||
'menu_name' => 'menu-test-menu',
|
||||
'mlid' => 141,
|
||||
'property' => 'title',
|
||||
'language' => 'zu',
|
||||
'link_title' => 'Test 3',
|
||||
'description' => 'Test menu link 3',
|
||||
'title_translated' => 'zu - title translation',
|
||||
'description_translated' => NULL,
|
||||
],
|
||||
];
|
||||
|
||||
return $test;
|
||||
}
|
||||
|
||||
}
|
|
@ -563,13 +563,9 @@ class Sql extends PluginBase implements MigrateIdMapInterface, ContainerFactoryP
|
|||
$conditions = [];
|
||||
foreach ($this->sourceIdFields() as $field_name => $db_field) {
|
||||
if ($is_associative) {
|
||||
// Ensure to handle array elements with a NULL value.
|
||||
if (array_key_exists($field_name, $source_id_values)) {
|
||||
// Associative $source_id_values can have fields out of order.
|
||||
if (isset($source_id_values[$field_name])) {
|
||||
// Only add a condition if the value is not NULL.
|
||||
$conditions[$db_field] = $source_id_values[$field_name];
|
||||
}
|
||||
// Associative $source_id_values can have fields out of order.
|
||||
if (isset($source_id_values[$field_name])) {
|
||||
$conditions[$db_field] = $source_id_values[$field_name];
|
||||
unset($source_id_values[$field_name]);
|
||||
}
|
||||
}
|
||||
|
@ -584,8 +580,7 @@ class Sql extends PluginBase implements MigrateIdMapInterface, ContainerFactoryP
|
|||
}
|
||||
|
||||
if (!empty($source_id_values)) {
|
||||
$var_dump = var_export($source_id_values, TRUE);
|
||||
throw new MigrateException(sprintf("Extra unknown items in source IDs: %s", $var_dump));
|
||||
throw new MigrateException("Extra unknown items in source IDs");
|
||||
}
|
||||
|
||||
$query = $this->getDatabase()->select($this->mapTableName(), 'map')
|
||||
|
|
|
@ -517,8 +517,6 @@ class MigrateSqlIdMapTest extends MigrateTestCase {
|
|||
$this->assertEquals([[101, 'en'], [101, 'fr'], [101, 'de']], $id_map->lookupDestinationIds(['nid' => 1]));
|
||||
$this->assertEquals([[102, 'en']], $id_map->lookupDestinationIds(['nid' => 2]));
|
||||
$this->assertEquals([], $id_map->lookupDestinationIds(['nid' => 99]));
|
||||
$this->assertEquals([[101, 'en'], [101, 'fr'], [101, 'de']], $id_map->lookupDestinationIds(['nid' => 1, 'language' => NULL]));
|
||||
$this->assertEquals([[102, 'en']], $id_map->lookupDestinationIds(['nid' => 2, 'language' => NULL]));
|
||||
// Out-of-order partial associative list.
|
||||
$this->assertEquals([[101, 'en'], [102, 'en']], $id_map->lookupDestinationIds(['language' => 'en']));
|
||||
$this->assertEquals([[101, 'fr']], $id_map->lookupDestinationIds(['language' => 'fr']));
|
||||
|
@ -529,14 +527,14 @@ class MigrateSqlIdMapTest extends MigrateTestCase {
|
|||
$this->fail('Too many source IDs should throw');
|
||||
}
|
||||
catch (MigrateException $e) {
|
||||
$this->assertEquals("Extra unknown items in source IDs: array (\n 0 => 3,\n)", $e->getMessage());
|
||||
$this->assertEquals("Extra unknown items in source IDs", $e->getMessage());
|
||||
}
|
||||
try {
|
||||
$id_map->lookupDestinationIds(['nid' => 1, 'aaa' => '2']);
|
||||
$this->fail('Unknown source ID key should throw');
|
||||
}
|
||||
catch (MigrateException $e) {
|
||||
$this->assertEquals("Extra unknown items in source IDs: array (\n 'aaa' => '2',\n)", $e->getMessage());
|
||||
$this->assertEquals("Extra unknown items in source IDs", $e->getMessage());
|
||||
}
|
||||
|
||||
// Verify that we are looking up by source_id_hash when all source IDs are
|
||||
|
|
|
@ -9710,38 +9710,6 @@ $connection->insert('i18n_strings')
|
|||
'objectindex' => '7',
|
||||
'format' => '0',
|
||||
))
|
||||
->values(array(
|
||||
'lid' => '1674',
|
||||
'objectid' => '463',
|
||||
'type' => 'item',
|
||||
'property' => 'title',
|
||||
'objectindex' => '463',
|
||||
'format' => '0',
|
||||
))
|
||||
->values(array(
|
||||
'lid' => '1675',
|
||||
'objectid' => '463',
|
||||
'type' => 'item',
|
||||
'property' => 'description',
|
||||
'objectindex' => '463',
|
||||
'format' => '0',
|
||||
))
|
||||
->values(array(
|
||||
'lid' => '1676',
|
||||
'objectid' => '138',
|
||||
'type' => 'item',
|
||||
'property' => 'title',
|
||||
'objectindex' => '138',
|
||||
'format' => '0',
|
||||
))
|
||||
->values(array(
|
||||
'lid' => '1677',
|
||||
'objectid' => '138',
|
||||
'type' => 'item',
|
||||
'property' => 'description',
|
||||
'objectindex' => '138',
|
||||
'format' => '0',
|
||||
))
|
||||
->execute();
|
||||
|
||||
$connection->schema()->createTable('i18n_variable', array(
|
||||
|
@ -22208,34 +22176,6 @@ $connection->insert('locales_source')
|
|||
'source' => 'Forums',
|
||||
'version' => '1',
|
||||
))
|
||||
->values(array(
|
||||
'lid' => '1674',
|
||||
'location' => 'item:463:title',
|
||||
'textgroup' => 'menu',
|
||||
'source' => 'fr - Test 1',
|
||||
'version' => '1',
|
||||
))
|
||||
->values(array(
|
||||
'lid' => '1675',
|
||||
'location' => 'item:463:description',
|
||||
'textgroup' => 'menu',
|
||||
'source' => 'fr - Test menu link 1',
|
||||
'version' => '1',
|
||||
))
|
||||
->values(array(
|
||||
'lid' => '1676',
|
||||
'location' => 'item:138:title',
|
||||
'textgroup' => 'menu',
|
||||
'source' => 'Test 1',
|
||||
'version' => '1',
|
||||
))
|
||||
->values(array(
|
||||
'lid' => '1677',
|
||||
'location' => 'item:138:description',
|
||||
'textgroup' => 'menu',
|
||||
'source' => 'Test menu link 1',
|
||||
'version' => '1',
|
||||
))
|
||||
->execute();
|
||||
|
||||
$connection->schema()->createTable('locales_target', array(
|
||||
|
@ -27765,7 +27705,7 @@ $connection->insert('menu_links')
|
|||
'link_path' => 'user/login',
|
||||
'router_path' => 'user/login',
|
||||
'link_title' => 'Test 1',
|
||||
'options' => 'a:2:{s:10:"attributes";a:1:{s:5:"title";s:16:"Test menu link 1";}s:8:"langcode";s:2:"en";}',
|
||||
'options' => 'a:1:{s:10:"attributes";a:1:{s:5:"title";s:16:"Test menu link 1";}}',
|
||||
'module' => 'menu',
|
||||
'hidden' => '0',
|
||||
'external' => '0',
|
||||
|
@ -33887,33 +33827,6 @@ $connection->insert('menu_links')
|
|||
'p9' => '0',
|
||||
'updated' => '0',
|
||||
))
|
||||
->values(array(
|
||||
'menu_name' => 'secondary-links',
|
||||
'mlid' => '463',
|
||||
'plid' => '139',
|
||||
'link_path' => 'user/login',
|
||||
'router_path' => 'user/login',
|
||||
'link_title' => 'fr - Test 1',
|
||||
'options' => 'a:3:{s:10:"attributes";a:1:{s:5:"title";s:21:"fr - Test menu link 1";}s:8:"langcode";s:2:"fr";s:5:"alter";b:1;}',
|
||||
'module' => 'menu',
|
||||
'hidden' => '0',
|
||||
'external' => '0',
|
||||
'has_children' => '0',
|
||||
'expanded' => '0',
|
||||
'weight' => '-49',
|
||||
'depth' => '2',
|
||||
'customized' => '1',
|
||||
'p1' => '139',
|
||||
'p2' => '459',
|
||||
'p3' => '0',
|
||||
'p4' => '0',
|
||||
'p5' => '0',
|
||||
'p6' => '0',
|
||||
'p7' => '0',
|
||||
'p8' => '0',
|
||||
'p9' => '0',
|
||||
'updated' => '0',
|
||||
))
|
||||
->execute();
|
||||
|
||||
$connection->schema()->createTable('menu_router', array(
|
||||
|
|
|
@ -89,7 +89,6 @@ class MigrateUpgrade6ReviewPageTest extends MigrateUpgradeReviewPageTestBase {
|
|||
'filefield_meta',
|
||||
'help',
|
||||
'i18n',
|
||||
'i18nmenu',
|
||||
'i18nstrings',
|
||||
'imageapi',
|
||||
'imageapi_gd',
|
||||
|
@ -124,6 +123,7 @@ class MigrateUpgrade6ReviewPageTest extends MigrateUpgradeReviewPageTestBase {
|
|||
'i18nblocks',
|
||||
'i18ncck',
|
||||
'i18ncontent',
|
||||
'i18nmenu',
|
||||
'i18npoll',
|
||||
'i18nprofile',
|
||||
'i18nsync',
|
||||
|
|
|
@ -68,7 +68,7 @@ class MigrateUpgrade6Test extends MigrateUpgradeExecuteTestBase {
|
|||
'file' => 8,
|
||||
'filter_format' => 7,
|
||||
'image_style' => 5,
|
||||
'language_content_settings' => 3,
|
||||
'language_content_settings' => 2,
|
||||
'migration' => 105,
|
||||
'node' => 17,
|
||||
// The 'book' module provides the 'book' node type, and the migration
|
||||
|
@ -85,7 +85,7 @@ class MigrateUpgrade6Test extends MigrateUpgradeExecuteTestBase {
|
|||
'tour' => 4,
|
||||
'user' => 7,
|
||||
'user_role' => 6,
|
||||
'menu_link_content' => 10,
|
||||
'menu_link_content' => 9,
|
||||
'view' => 16,
|
||||
'date_format' => 11,
|
||||
'entity_form_display' => 29,
|
||||
|
@ -106,7 +106,7 @@ class MigrateUpgrade6Test extends MigrateUpgradeExecuteTestBase {
|
|||
$counts['entity_view_display'] = 53;
|
||||
$counts['entity_view_mode'] = 14;
|
||||
$counts['file'] = 9;
|
||||
$counts['menu_link_content'] = 11;
|
||||
$counts['menu_link_content'] = 10;
|
||||
$counts['node'] = 18;
|
||||
$counts['taxonomy_term'] = 9;
|
||||
$counts['user'] = 8;
|
||||
|
@ -131,7 +131,6 @@ class MigrateUpgrade6Test extends MigrateUpgradeExecuteTestBase {
|
|||
'filefield',
|
||||
'filter',
|
||||
'forum',
|
||||
'i18nmenu',
|
||||
'i18ntaxonomy',
|
||||
'imagecache',
|
||||
'imagefield',
|
||||
|
@ -176,6 +175,7 @@ class MigrateUpgrade6Test extends MigrateUpgradeExecuteTestBase {
|
|||
'i18nblocks',
|
||||
'i18ncck',
|
||||
'i18ncontent',
|
||||
'i18nmenu',
|
||||
// This module is in the missing path list because it is installed on the
|
||||
// source site but it is not installed on the destination site.
|
||||
'i18nprofile',
|
||||
|
|
|
@ -1,66 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\system\Plugin\migrate\source;
|
||||
|
||||
use Drupal\migrate\Row;
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
|
||||
/**
|
||||
* Gets system data for a legacy extension.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "extension",
|
||||
* source_module = "system"
|
||||
* )
|
||||
*/
|
||||
class Extension extends DrupalSqlBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$query = $this->select('system', 's')
|
||||
->fields('s');
|
||||
|
||||
if (isset($this->configuration['name'])) {
|
||||
$query->condition('name', (array) $this->configuration['name'], 'IN');
|
||||
}
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
$fields = [
|
||||
'filename' => $this->t('Filename'),
|
||||
'name' => $this->t('Name'),
|
||||
'type' => $this->t('Type'),
|
||||
'owner' => $this->t('Owner'),
|
||||
'status' => $this->t('Status'),
|
||||
'throttle' => $this->t('Throttle'),
|
||||
'bootstrap' => $this->t('Bootstrap'),
|
||||
'schema_version' => $this->t('Schema version'),
|
||||
'weight' => $this->t('Weight'),
|
||||
'info' => $this->t('Information array'),
|
||||
];
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function prepareRow(Row $row) {
|
||||
$row->setSourceProperty('info', unserialize($row->getSourceProperty('info')));
|
||||
return parent::prepareRow($row);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['name']['type'] = 'string';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,77 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\system\Kernel\Plugin\migrate\source;
|
||||
|
||||
use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
|
||||
|
||||
/**
|
||||
* Tests legacy extension source plugin.
|
||||
*
|
||||
* @covers \Drupal\system\Plugin\migrate\source\Extension
|
||||
* @group migrate_drupal
|
||||
*/
|
||||
class ExtensionTest extends MigrateSqlSourceTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['system', 'migrate_drupal'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function providerSource() {
|
||||
$test = [];
|
||||
|
||||
$test[0]['source_data']['system'] = [
|
||||
[
|
||||
'filename' => 'sites/all/modules/i18n/i18nmenu/i18nmenu.module',
|
||||
'name' => 'i18nmenu',
|
||||
'type' => 'module',
|
||||
'owner' => '',
|
||||
'status' => '1',
|
||||
'throttle' => '0',
|
||||
'bootstrap' => '0',
|
||||
'schema_version' => '0',
|
||||
'weight' => '0',
|
||||
'info' => 'a:10:{s:4:"name";s:16:"Menu translation";s:11:"description";s:40:"Supports translatable custom menu items.";s:12:"dependencies";a:4:{i:0;s:4:"i18n";i:1;s:4:"menu";i:2;s:10:"i18nblocks";i:3;s:11:"i18nstrings";}s:7:"package";s:13:"Multilanguage";s:4:"core";s:3:"6.x";s:7:"version";s:8:"6.x-1.10";s:7:"project";s:4:"i18n";s:9:"datestamp";s:10:"1318336004";s:10:"dependents";a:0:{}s:3:"php";s:5:"4.3.5";},',
|
||||
],
|
||||
[
|
||||
'filename' => 'sites/all/modules/variable/variable.module ',
|
||||
'name' => 'variable',
|
||||
'type' => 'module',
|
||||
'owner' => '',
|
||||
'status' => '1',
|
||||
'throttle' => '0',
|
||||
'bootstrap' => '0',
|
||||
'schema_version' => '-1',
|
||||
'weight' => '0',
|
||||
'info' => 'a:9:{s:4:"name";s:12:"Variable API";s:11:"description";s:12:"Variable API";s:4:"core";s:3:"6.x";s:7:"version";s:14:"6.x-1.0-alpha1";s:7:"project";s:8:"variable";s:9:"datestamp";s:10:"1414059742";s:12:"dependencies";a:0:{}s:10:"dependents";a:0:{}s:3:"php";s:5:"4.3.5";}',
|
||||
],
|
||||
];
|
||||
|
||||
$info = unserialize('a:9:{s:4:"name";s:12:"Variable API";s:11:"description";s:12:"Variable API";s:4:"core";s:3:"6.x";s:7:"version";s:14:"6.x-1.0-alpha1";s:7:"project";s:8:"variable";s:9:"datestamp";s:10:"1414059742";s:12:"dependencies";a:0:{}s:10:"dependents";a:0:{}s:3:"php";s:5:"4.3.5";}');
|
||||
$test[0]['expected_results'] = [
|
||||
[
|
||||
'filename' => 'sites/all/modules/variable/variable.module ',
|
||||
'name' => 'variable',
|
||||
'type' => 'module',
|
||||
'owner' => '',
|
||||
'status' => '1',
|
||||
'throttle' => '0',
|
||||
'bootstrap' => '0',
|
||||
'schema_version' => '-1',
|
||||
'weight' => '0',
|
||||
'info' => $info,
|
||||
],
|
||||
];
|
||||
|
||||
$test[0]['expected_count'] = NULL;
|
||||
$test[0]['configuration'] = [
|
||||
'name' => 'variable',
|
||||
];
|
||||
|
||||
return $test;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue