Update to Drupal 8.1.9. For more information, see https://www.drupal.org/project/drupal/releases/8.1.9
This commit is contained in:
parent
f9f23cdf38
commit
09b113657a
125 changed files with 2307 additions and 385 deletions
|
@ -15,7 +15,7 @@ use Drupal\migrate\Plugin\MigrationInterface;
|
|||
*
|
||||
* @ingroup migration
|
||||
*/
|
||||
class MigrateCckFieldPluginManager extends MigratePluginManager {
|
||||
class MigrateCckFieldPluginManager extends MigratePluginManager implements MigrateCckFieldPluginManagerInterface {
|
||||
|
||||
/**
|
||||
* The default version of core to use for cck field plugins.
|
||||
|
@ -29,7 +29,7 @@ class MigrateCckFieldPluginManager extends MigratePluginManager {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function createInstance($field_type, array $configuration = array(), MigrationInterface $migration = NULL) {
|
||||
public function getPluginIdFromFieldType($field_type, array $configuration = [], MigrationInterface $migration = NULL) {
|
||||
$core = static::DEFAULT_CORE_VERSION;
|
||||
if (!empty($configuration['core'])) {
|
||||
$core = $configuration['core'];
|
||||
|
@ -45,7 +45,7 @@ class MigrateCckFieldPluginManager extends MigratePluginManager {
|
|||
foreach ($this->getDefinitions() as $plugin_id => $definition) {
|
||||
if (in_array($core, $definition['core'])) {
|
||||
if (array_key_exists($field_type, $definition['type_map']) || $field_type === $plugin_id) {
|
||||
return parent::createInstance($plugin_id, $configuration, $migration);
|
||||
return $plugin_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin;
|
||||
|
||||
use Drupal\migrate\Plugin\MigratePluginManagerInterface;
|
||||
use Drupal\migrate\Plugin\MigrationInterface;
|
||||
|
||||
interface MigrateCckFieldPluginManagerInterface extends MigratePluginManagerInterface {
|
||||
|
||||
/**
|
||||
* Get the plugin ID from the field type.
|
||||
*
|
||||
* @param string $field_type
|
||||
* The field type being migrated.
|
||||
* @param array $configuration
|
||||
* (optional) An array of configuration relevant to the plugin instance.
|
||||
* @param \Drupal\migrate\Plugin\MigrationInterface|null $migration
|
||||
* (optional) The current migration instance.
|
||||
*
|
||||
* @return string
|
||||
* The ID of the plugin for the field_type if available.
|
||||
*
|
||||
* @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
|
||||
* If the plugin cannot be determined, such as if the field type is invalid.
|
||||
*/
|
||||
public function getPluginIdFromFieldType($field_type, array $configuration = [], MigrationInterface $migration = NULL);
|
||||
|
||||
}
|
|
@ -2,13 +2,15 @@
|
|||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate;
|
||||
|
||||
use Drupal\Component\Plugin\Exception\PluginNotFoundException;
|
||||
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
||||
use Drupal\migrate\Exception\RequirementsException;
|
||||
use Drupal\migrate\Plugin\MigrateDestinationPluginManager;
|
||||
use Drupal\migrate\Plugin\MigratePluginManager;
|
||||
use Drupal\migrate\Plugin\MigratePluginManagerInterface;
|
||||
use Drupal\migrate\Plugin\Migration;
|
||||
use Drupal\migrate\Plugin\MigrationPluginManagerInterface;
|
||||
use Drupal\migrate\Plugin\RequirementsInterface;
|
||||
use Drupal\migrate_drupal\Plugin\MigrateCckFieldPluginManagerInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
/**
|
||||
|
@ -40,7 +42,7 @@ class CckMigration extends Migration implements ContainerFactoryPluginInterface
|
|||
/**
|
||||
* The cckfield plugin manager.
|
||||
*
|
||||
* @var \Drupal\migrate\Plugin\MigratePluginManager
|
||||
* @var \Drupal\migrate_drupal\Plugin\MigrateCckFieldPluginManagerInterface
|
||||
*/
|
||||
protected $cckPluginManager;
|
||||
|
||||
|
@ -53,20 +55,20 @@ class CckMigration extends Migration implements ContainerFactoryPluginInterface
|
|||
* The plugin ID.
|
||||
* @param mixed $plugin_definition
|
||||
* The plugin definition.
|
||||
* @param \Drupal\migrate\Plugin\MigratePluginManager $cck_manager
|
||||
* @param \Drupal\migrate_drupal\Plugin\MigrateCckFieldPluginManagerInterface $cck_manager
|
||||
* The cckfield plugin manager.
|
||||
* @param \Drupal\migrate\Plugin\MigrationPluginManagerInterface $migration_plugin_manager
|
||||
* The migration plugin manager.
|
||||
* @param \Drupal\migrate\Plugin\MigratePluginManager $source_plugin_manager
|
||||
* @param \Drupal\migrate\Plugin\MigratePluginManagerInterface $source_plugin_manager
|
||||
* The source migration plugin manager.
|
||||
* @param \Drupal\migrate\Plugin\MigratePluginManager $process_plugin_manager
|
||||
* @param \Drupal\migrate\Plugin\MigratePluginManagerInterface $process_plugin_manager
|
||||
* The process migration plugin manager.
|
||||
* @param \Drupal\migrate\Plugin\MigrateDestinationPluginManager $destination_plugin_manager
|
||||
* The destination migration plugin manager.
|
||||
* @param \Drupal\migrate\Plugin\MigratePluginManager $idmap_plugin_manager
|
||||
* @param \Drupal\migrate\Plugin\MigratePluginManagerInterface $idmap_plugin_manager
|
||||
* The ID map migration plugin manager.
|
||||
*/
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition, MigratePluginManager $cck_manager, MigrationPluginManagerInterface $migration_plugin_manager, MigratePluginManager $source_plugin_manager, MigratePluginManager $process_plugin_manager, MigrateDestinationPluginManager $destination_plugin_manager, MigratePluginManager $idmap_plugin_manager) {
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrateCckFieldPluginManagerInterface $cck_manager, MigrationPluginManagerInterface $migration_plugin_manager, MigratePluginManagerInterface $source_plugin_manager, MigratePluginManagerInterface $process_plugin_manager, MigrateDestinationPluginManager $destination_plugin_manager, MigratePluginManagerInterface $idmap_plugin_manager) {
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition, $migration_plugin_manager, $source_plugin_manager, $process_plugin_manager, $destination_plugin_manager, $idmap_plugin_manager);
|
||||
$this->cckPluginManager = $cck_manager;
|
||||
}
|
||||
|
@ -106,12 +108,19 @@ class CckMigration extends Migration implements ContainerFactoryPluginInterface
|
|||
}
|
||||
foreach ($source_plugin as $row) {
|
||||
$field_type = $row->getSourceProperty('type');
|
||||
if (!isset($this->processedFieldTypes[$field_type]) && $this->cckPluginManager->hasDefinition($field_type)) {
|
||||
try {
|
||||
$plugin_id = $this->cckPluginManager->getPluginIdFromFieldType($field_type, [], $this);
|
||||
}
|
||||
catch (PluginNotFoundException $ex) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isset($this->processedFieldTypes[$field_type])) {
|
||||
$this->processedFieldTypes[$field_type] = TRUE;
|
||||
// Allow the cckfield plugin to alter the migration as necessary so
|
||||
// that it knows how to handle fields of this type.
|
||||
if (!isset($this->cckPluginCache[$field_type])) {
|
||||
$this->cckPluginCache[$field_type] = $this->cckPluginManager->createInstance($field_type, [], $this);
|
||||
$this->cckPluginCache[$field_type] = $this->cckPluginManager->createInstance($plugin_id, [], $this);
|
||||
}
|
||||
call_user_func([$this->cckPluginCache[$field_type], $this->pluginDefinition['cck_plugin_method']], $this);
|
||||
}
|
||||
|
|
|
@ -3835,6 +3835,18 @@ $connection->insert('field_data_body')
|
|||
'body_summary' => '',
|
||||
'body_format' => 'filtered_html',
|
||||
))
|
||||
->values(array(
|
||||
'entity_type' => 'node',
|
||||
'bundle' => 'article',
|
||||
'deleted' => '0',
|
||||
'entity_id' => '3',
|
||||
'revision_id' => '3',
|
||||
'language' => 'und',
|
||||
'delta' => '0',
|
||||
'body_value' => "is - ...is that it's the absolute best show ever. Trust me, I would know.",
|
||||
'body_summary' => '',
|
||||
'body_format' => 'filtered_html',
|
||||
))
|
||||
->execute();
|
||||
|
||||
$connection->schema()->createTable('field_data_comment_body', array(
|
||||
|
@ -4930,6 +4942,18 @@ $connection->insert('field_data_field_link')
|
|||
'field_link_title' => 'Home',
|
||||
'field_link_attributes' => 'a:0:{}',
|
||||
))
|
||||
->values(array(
|
||||
'entity_type' => 'node',
|
||||
'bundle' => 'article',
|
||||
'deleted' => '0',
|
||||
'entity_id' => '3',
|
||||
'revision_id' => '3',
|
||||
'language' => 'und',
|
||||
'delta' => '0',
|
||||
'field_link_url' => '<front>',
|
||||
'field_link_title' => 'Home',
|
||||
'field_link_attributes' => 'a:1:{s:5:"title";s:0:"";}',
|
||||
))
|
||||
->execute();
|
||||
|
||||
$connection->schema()->createTable('field_data_field_long_text', array(
|
||||
|
@ -5167,6 +5191,16 @@ $connection->insert('field_data_field_tags')
|
|||
'delta' => '0',
|
||||
'field_tags_tid' => '9',
|
||||
))
|
||||
->values(array(
|
||||
'entity_type' => 'node',
|
||||
'bundle' => 'article',
|
||||
'deleted' => '0',
|
||||
'entity_id' => '3',
|
||||
'revision_id' => '3',
|
||||
'language' => 'und',
|
||||
'delta' => '0',
|
||||
'field_tags_tid' => '9',
|
||||
))
|
||||
->values(array(
|
||||
'entity_type' => 'node',
|
||||
'bundle' => 'article',
|
||||
|
@ -5177,6 +5211,16 @@ $connection->insert('field_data_field_tags')
|
|||
'delta' => '1',
|
||||
'field_tags_tid' => '14',
|
||||
))
|
||||
->values(array(
|
||||
'entity_type' => 'node',
|
||||
'bundle' => 'article',
|
||||
'deleted' => '0',
|
||||
'entity_id' => '3',
|
||||
'revision_id' => '3',
|
||||
'language' => 'und',
|
||||
'delta' => '1',
|
||||
'field_tags_tid' => '14',
|
||||
))
|
||||
->values(array(
|
||||
'entity_type' => 'node',
|
||||
'bundle' => 'article',
|
||||
|
@ -5187,6 +5231,16 @@ $connection->insert('field_data_field_tags')
|
|||
'delta' => '2',
|
||||
'field_tags_tid' => '17',
|
||||
))
|
||||
->values(array(
|
||||
'entity_type' => 'node',
|
||||
'bundle' => 'article',
|
||||
'deleted' => '0',
|
||||
'entity_id' => '3',
|
||||
'revision_id' => '3',
|
||||
'language' => 'und',
|
||||
'delta' => '2',
|
||||
'field_tags_tid' => '17',
|
||||
))
|
||||
->execute();
|
||||
|
||||
$connection->schema()->createTable('field_data_field_term_reference', array(
|
||||
|
@ -5603,6 +5657,18 @@ $connection->insert('field_revision_body')
|
|||
'body_summary' => '',
|
||||
'body_format' => 'filtered_html',
|
||||
))
|
||||
->values(array(
|
||||
'entity_type' => 'node',
|
||||
'bundle' => 'article',
|
||||
'deleted' => '0',
|
||||
'entity_id' => '3',
|
||||
'revision_id' => '3',
|
||||
'language' => 'und',
|
||||
'delta' => '0',
|
||||
'body_value' => "is - ...is that it's the absolute best show ever. Trust me, I would know.",
|
||||
'body_summary' => '',
|
||||
'body_format' => 'filtered_html',
|
||||
))
|
||||
->execute();
|
||||
|
||||
$connection->schema()->createTable('field_revision_comment_body', array(
|
||||
|
@ -6710,6 +6776,18 @@ $connection->insert('field_revision_field_link')
|
|||
'field_link_title' => 'Home',
|
||||
'field_link_attributes' => 'a:0:{}',
|
||||
))
|
||||
->values(array(
|
||||
'entity_type' => 'node',
|
||||
'bundle' => 'article',
|
||||
'deleted' => '0',
|
||||
'entity_id' => '3',
|
||||
'revision_id' => '3',
|
||||
'language' => 'und',
|
||||
'delta' => '0',
|
||||
'field_link_url' => '<front>',
|
||||
'field_link_title' => 'Home',
|
||||
'field_link_attributes' => 'a:1:{s:5:"title";s:0:"";}',
|
||||
))
|
||||
->execute();
|
||||
|
||||
$connection->schema()->createTable('field_revision_field_long_text', array(
|
||||
|
@ -6950,6 +7028,16 @@ $connection->insert('field_revision_field_tags')
|
|||
'delta' => '0',
|
||||
'field_tags_tid' => '9',
|
||||
))
|
||||
->values(array(
|
||||
'entity_type' => 'node',
|
||||
'bundle' => 'article',
|
||||
'deleted' => '0',
|
||||
'entity_id' => '3',
|
||||
'revision_id' => '3',
|
||||
'language' => 'und',
|
||||
'delta' => '0',
|
||||
'field_tags_tid' => '9',
|
||||
))
|
||||
->values(array(
|
||||
'entity_type' => 'node',
|
||||
'bundle' => 'article',
|
||||
|
@ -6960,6 +7048,16 @@ $connection->insert('field_revision_field_tags')
|
|||
'delta' => '1',
|
||||
'field_tags_tid' => '14',
|
||||
))
|
||||
->values(array(
|
||||
'entity_type' => 'node',
|
||||
'bundle' => 'article',
|
||||
'deleted' => '0',
|
||||
'entity_id' => '3',
|
||||
'revision_id' => '3',
|
||||
'language' => 'und',
|
||||
'delta' => '1',
|
||||
'field_tags_tid' => '14',
|
||||
))
|
||||
->values(array(
|
||||
'entity_type' => 'node',
|
||||
'bundle' => 'article',
|
||||
|
@ -6970,6 +7068,16 @@ $connection->insert('field_revision_field_tags')
|
|||
'delta' => '2',
|
||||
'field_tags_tid' => '17',
|
||||
))
|
||||
->values(array(
|
||||
'entity_type' => 'node',
|
||||
'bundle' => 'article',
|
||||
'deleted' => '0',
|
||||
'entity_id' => '3',
|
||||
'revision_id' => '3',
|
||||
'language' => 'und',
|
||||
'delta' => '2',
|
||||
'field_tags_tid' => '17',
|
||||
))
|
||||
->execute();
|
||||
|
||||
$connection->schema()->createTable('field_revision_field_term_reference', array(
|
||||
|
@ -29674,7 +29782,23 @@ $connection->insert('node')
|
|||
'comment' => '2',
|
||||
'promote' => '1',
|
||||
'sticky' => '0',
|
||||
'tnid' => '0',
|
||||
'tnid' => '2',
|
||||
'translate' => '0',
|
||||
))
|
||||
->values(array(
|
||||
'nid' => '3',
|
||||
'vid' => '3',
|
||||
'type' => 'article',
|
||||
'language' => 'is',
|
||||
'title' => 'is - The thing about Deep Space 9',
|
||||
'uid' => '1',
|
||||
'status' => '1',
|
||||
'created' => '1471428152',
|
||||
'changed' => '1471428152',
|
||||
'comment' => '2',
|
||||
'promote' => '1',
|
||||
'sticky' => '0',
|
||||
'tnid' => '2',
|
||||
'translate' => '0',
|
||||
))
|
||||
->execute();
|
||||
|
@ -29813,6 +29937,14 @@ $connection->insert('node_comment_statistics')
|
|||
'last_comment_uid' => '1',
|
||||
'comment_count' => '1',
|
||||
))
|
||||
->values(array(
|
||||
'nid' => '3',
|
||||
'cid' => '0',
|
||||
'last_comment_timestamp' => '1471428152',
|
||||
'last_comment_name' => NULL,
|
||||
'last_comment_uid' => '1',
|
||||
'comment_count' => '0',
|
||||
))
|
||||
->execute();
|
||||
|
||||
$connection->schema()->createTable('node_counter', array(
|
||||
|
@ -29864,6 +29996,18 @@ $connection->insert('node_counter')
|
|||
'daycount' => '0',
|
||||
'timestamp' => '1421727536',
|
||||
))
|
||||
->values(array(
|
||||
'nid' => '2',
|
||||
'totalcount' => '1',
|
||||
'daycount' => '1',
|
||||
'timestamp' => '1471428059',
|
||||
))
|
||||
->values(array(
|
||||
'nid' => '3',
|
||||
'totalcount' => '1',
|
||||
'daycount' => '1',
|
||||
'timestamp' => '1471428153',
|
||||
))
|
||||
->execute();
|
||||
|
||||
$connection->schema()->createTable('node_revision', array(
|
||||
|
@ -29972,6 +30116,18 @@ $connection->insert('node_revision')
|
|||
'promote' => '1',
|
||||
'sticky' => '0',
|
||||
))
|
||||
->values(array(
|
||||
'nid' => '3',
|
||||
'vid' => '3',
|
||||
'uid' => '1',
|
||||
'title' => 'is - The thing about Deep Space 9',
|
||||
'log' => '',
|
||||
'timestamp' => '1471428152',
|
||||
'status' => '1',
|
||||
'comment' => '2',
|
||||
'promote' => '1',
|
||||
'sticky' => '0',
|
||||
))
|
||||
->execute();
|
||||
|
||||
$connection->schema()->createTable('node_type', array(
|
||||
|
@ -40112,6 +40268,24 @@ $connection->insert('taxonomy_index')
|
|||
'sticky' => '0',
|
||||
'created' => '1441306772',
|
||||
))
|
||||
->values(array(
|
||||
'nid' => '3',
|
||||
'tid' => '9',
|
||||
'sticky' => '0',
|
||||
'created' => '1471428152',
|
||||
))
|
||||
->values(array(
|
||||
'nid' => '3',
|
||||
'tid' => '14',
|
||||
'sticky' => '0',
|
||||
'created' => '1471428152',
|
||||
))
|
||||
->values(array(
|
||||
'nid' => '3',
|
||||
'tid' => '17',
|
||||
'sticky' => '0',
|
||||
'created' => '1471428152',
|
||||
))
|
||||
->execute();
|
||||
|
||||
$connection->schema()->createTable('taxonomy_term_data', array(
|
||||
|
@ -41342,7 +41516,7 @@ $connection->insert('variable')
|
|||
))
|
||||
->values(array(
|
||||
'name' => 'language_content_type_article',
|
||||
'value' => 's:1:"0";',
|
||||
'value' => 's:1:"2";',
|
||||
))
|
||||
->values(array(
|
||||
'name' => 'language_content_type_blog',
|
||||
|
@ -41442,7 +41616,7 @@ $connection->insert('variable')
|
|||
))
|
||||
->values(array(
|
||||
'name' => 'menu_override_parent_selector',
|
||||
'value' => 'b:1;',
|
||||
'value' => 'b:0;',
|
||||
))
|
||||
->values(array(
|
||||
'name' => 'menu_parent_article',
|
||||
|
|
|
@ -22,32 +22,33 @@ class MigrateCckFieldPluginManagerTest extends MigrateDrupalTestBase {
|
|||
public function testPluginSelection() {
|
||||
$plugin_manager = \Drupal::service('plugin.manager.migrate.cckfield');
|
||||
|
||||
$this->assertIdentical('Drupal\\file\\Plugin\\migrate\\cckfield\\d6\\FileField', get_class($plugin_manager->createInstance('filefield', ['core' => 6])));
|
||||
$plugin_id = $plugin_manager->getPluginIdFromFieldType('filefield', ['core' => 6]);
|
||||
$this->assertIdentical('Drupal\\file\\Plugin\\migrate\\cckfield\\d6\\FileField', get_class($plugin_manager->createInstance($plugin_id, ['core' => 6])));
|
||||
|
||||
try {
|
||||
// If this test passes, createInstance will raise a
|
||||
// If this test passes, getPluginIdFromFieldType will raise a
|
||||
// PluginNotFoundException and we'll never reach fail().
|
||||
$plugin_manager->createInstance('filefield', ['core' => 7]);
|
||||
$plugin_manager->getPluginIdFromFieldType('filefield', ['core' => 7]);
|
||||
$this->fail('Expected Drupal\Component\Plugin\Exception\PluginNotFoundException.');
|
||||
}
|
||||
catch (PluginNotFoundException $e) {
|
||||
$this->assertIdentical($e->getMessage(), "Plugin ID 'filefield' was not found.");
|
||||
}
|
||||
|
||||
$this->assertIdentical('Drupal\\file\\Plugin\\migrate\\cckfield\\d7\\ImageField', get_class($plugin_manager->createInstance('image', ['core' => 7])));
|
||||
$this->assertIdentical('Drupal\\file\\Plugin\\migrate\\cckfield\\d7\\FileField', get_class($plugin_manager->createInstance('file', ['core' => 7])));
|
||||
$this->assertIdentical('Drupal\\migrate_cckfield_plugin_manager_test\\Plugin\\migrate\\cckfield\\D6FileField', get_class($plugin_manager->createInstance('file', ['core' => 6])));
|
||||
$this->assertIdentical('image', $plugin_manager->getPluginIdFromFieldType('image', ['core' => 7]));
|
||||
$this->assertIdentical('file', $plugin_manager->getPluginIdFromFieldType('file', ['core' => 7]));
|
||||
$this->assertIdentical('d6_file', $plugin_manager->getPluginIdFromFieldType('file', ['core' => 6]));
|
||||
|
||||
$this->assertIdentical('Drupal\\text\\Plugin\\migrate\\cckfield\\TextField', get_class($plugin_manager->createInstance('text', ['core' => 6])));
|
||||
$this->assertIdentical('Drupal\\text\\Plugin\\migrate\\cckfield\\TextField', get_class($plugin_manager->createInstance('text', ['core' => 7])));
|
||||
$this->assertIdentical('text', $plugin_manager->getPluginIdFromFieldType('text', ['core' => 6]));
|
||||
$this->assertIdentical('text', $plugin_manager->getPluginIdFromFieldType('text', ['core' => 7]));
|
||||
|
||||
// Test fallback when no core version is specified.
|
||||
$this->assertIdentical('Drupal\\migrate_cckfield_plugin_manager_test\\Plugin\\migrate\\cckfield\\D6NoCoreVersionSpecified', get_class($plugin_manager->createInstance('d6_no_core_version_specified', ['core' => 6])));
|
||||
$this->assertIdentical('d6_no_core_version_specified', $plugin_manager->getPluginIdFromFieldType('d6_no_core_version_specified', ['core' => 6]));
|
||||
|
||||
try {
|
||||
// If this test passes, createInstance will raise a
|
||||
// If this test passes, getPluginIdFromFieldType will raise a
|
||||
// PluginNotFoundException and we'll never reach fail().
|
||||
$plugin_manager->createInstance('d6_no_core_version_specified', ['core' => 7]);
|
||||
$plugin_manager->getPluginIdFromFieldType('d6_no_core_version_specified', ['core' => 7]);
|
||||
$this->fail('Expected Drupal\Component\Plugin\Exception\PluginNotFoundException.');
|
||||
}
|
||||
catch (PluginNotFoundException $e) {
|
||||
|
|
Reference in a new issue