Update to Drupal 8.1.8. For more information, see https://www.drupal.org/project/drupal/releases/8.1.8
This commit is contained in:
parent
e9f047ccf8
commit
f9f23cdf38
312 changed files with 6751 additions and 1546 deletions
|
@ -0,0 +1,8 @@
|
|||
name: 'Migration external translated test'
|
||||
type: module
|
||||
package: Testing
|
||||
version: VERSION
|
||||
core: 8.x
|
||||
dependencies:
|
||||
- node
|
||||
- migrate
|
|
@ -0,0 +1,19 @@
|
|||
id: external_translated_test_node
|
||||
label: External translated content
|
||||
source:
|
||||
plugin: migrate_external_translated_test
|
||||
default_lang: true
|
||||
constants:
|
||||
type: external_test
|
||||
process:
|
||||
type: constants/type
|
||||
title: title
|
||||
langcode:
|
||||
plugin: static_map
|
||||
source: lang
|
||||
map:
|
||||
English: en
|
||||
French: fr
|
||||
Spanish: es
|
||||
destination:
|
||||
plugin: entity:node
|
|
@ -0,0 +1,27 @@
|
|||
id: external_translated_test_node_translation
|
||||
label: External translated content translations
|
||||
source:
|
||||
plugin: migrate_external_translated_test
|
||||
default_lang: false
|
||||
constants:
|
||||
type: external_test
|
||||
process:
|
||||
nid:
|
||||
plugin: migration
|
||||
source: name
|
||||
migration: external_translated_test_node
|
||||
type: constants/type
|
||||
title: title
|
||||
langcode:
|
||||
plugin: static_map
|
||||
source: lang
|
||||
map:
|
||||
English: en
|
||||
French: fr
|
||||
Spanish: es
|
||||
destination:
|
||||
plugin: entity:node
|
||||
translations: true
|
||||
migration_dependencies:
|
||||
required:
|
||||
- external_translated_test_node
|
|
@ -0,0 +1,77 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\migrate_external_translated_test\Plugin\migrate\source;
|
||||
|
||||
use Drupal\migrate\Plugin\migrate\source\SourcePluginBase;
|
||||
|
||||
/**
|
||||
* A simple migrate source for our tests.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "migrate_external_translated_test"
|
||||
* )
|
||||
*/
|
||||
class MigrateExternalTranslatedTestSource extends SourcePluginBase {
|
||||
|
||||
/**
|
||||
* The data to import.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $import = [
|
||||
['name' => 'cat', 'title' => 'Cat', 'lang' => 'English'],
|
||||
['name' => 'cat', 'title' => 'Chat', 'lang' => 'French'],
|
||||
['name' => 'cat', 'title' => 'Gato', 'lang' => 'Spanish'],
|
||||
['name' => 'dog', 'title' => 'Dog', 'lang' => 'English'],
|
||||
['name' => 'dog', 'title' => 'Chien', 'lang' => 'French'],
|
||||
['name' => 'monkey', 'title' => 'Monkey', 'lang' => 'English'],
|
||||
];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return [
|
||||
'name' => $this->t('Unique name'),
|
||||
'title' => $this->t('Title'),
|
||||
'lang' => $this->t('Language'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __toString() {
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['name']['type'] = 'string';
|
||||
if (!$this->configuration['default_lang']) {
|
||||
$ids['lang']['type'] = 'string';
|
||||
}
|
||||
return $ids;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function initializeIterator() {
|
||||
$data = [];
|
||||
|
||||
// Keep the rows with the right languages.
|
||||
$want_default = $this->configuration['default_lang'];
|
||||
foreach ($this->import as $row) {
|
||||
$is_english = $row['lang'] == 'English';
|
||||
if ($want_default == $is_english) {
|
||||
$data[] = $row;
|
||||
}
|
||||
}
|
||||
|
||||
return new \ArrayIterator($data);
|
||||
}
|
||||
|
||||
}
|
Reference in a new issue