Update to Drupal 8.1.0. For more information, see https://www.drupal.org/drupal-8.1.0-release-notes
This commit is contained in:
parent
b11a755ba8
commit
c0a0d5a94c
6920 changed files with 64395 additions and 57312 deletions
|
@ -1,192 +0,0 @@
|
|||
# Schema for the migrate_drupal source plugins.
|
||||
|
||||
migrate.source.variable:
|
||||
type: migrate_source_sql
|
||||
label: 'Variable'
|
||||
mapping:
|
||||
variables:
|
||||
type: sequence
|
||||
label: 'Variables'
|
||||
sequence:
|
||||
type: string
|
||||
label: 'Variable'
|
||||
constants:
|
||||
type: mapping
|
||||
label: 'Constants'
|
||||
mapping:
|
||||
entity_type:
|
||||
type: string
|
||||
label: 'Entity type'
|
||||
id:
|
||||
type: string
|
||||
label: 'ID'
|
||||
label:
|
||||
type: label
|
||||
label: 'Label'
|
||||
description:
|
||||
type: text
|
||||
label: 'Description'
|
||||
path:
|
||||
type: string
|
||||
label: 'Path'
|
||||
plugin:
|
||||
type: string
|
||||
label: 'Plugin'
|
||||
status:
|
||||
type: boolean
|
||||
label: 'Status'
|
||||
slash:
|
||||
type: string
|
||||
label: 'Slash'
|
||||
|
||||
migrate.source.variable_multirow:
|
||||
type: migrate_source_sql
|
||||
label: 'Drupal variable multirow'
|
||||
mapping:
|
||||
variables:
|
||||
type: sequence
|
||||
label: 'Variables'
|
||||
sequence:
|
||||
type: string
|
||||
label: 'Variable'
|
||||
|
||||
migrate_entity_constant:
|
||||
type: mapping
|
||||
mapping:
|
||||
entity_type:
|
||||
type: string
|
||||
label: 'Entity type'
|
||||
bundle:
|
||||
type: string
|
||||
label: 'Bundle'
|
||||
label:
|
||||
type: label
|
||||
label: 'Label'
|
||||
id:
|
||||
type: string
|
||||
label: 'ID'
|
||||
target_entity_type:
|
||||
type: string
|
||||
label: 'Target entity type'
|
||||
view_mode:
|
||||
type: string
|
||||
label: 'View mode'
|
||||
form_mode:
|
||||
type: string
|
||||
label: 'Form mode'
|
||||
field_name:
|
||||
type: string
|
||||
label: 'Field name'
|
||||
empty:
|
||||
type: sequence
|
||||
label: 'Empty'
|
||||
sequence:
|
||||
type: string
|
||||
label: 'Empty'
|
||||
name:
|
||||
type: string
|
||||
label: 'Name'
|
||||
preview:
|
||||
type: integer
|
||||
label: 'Preview'
|
||||
create_body:
|
||||
type: boolean
|
||||
label: 'create body'
|
||||
required:
|
||||
type: boolean
|
||||
label: 'Required'
|
||||
type:
|
||||
type: string
|
||||
label: 'Type'
|
||||
cardinality:
|
||||
type: integer
|
||||
label: 'Cardinality'
|
||||
parent:
|
||||
type: integer
|
||||
label: 'Parent'
|
||||
langcode:
|
||||
type: string
|
||||
label: 'Language code'
|
||||
third_party_settings:
|
||||
type: sequence
|
||||
label: 'Settings'
|
||||
sequence:
|
||||
type: ignore
|
||||
label: 'Settings'
|
||||
settings:
|
||||
type: sequence
|
||||
label: 'Settings'
|
||||
sequence:
|
||||
type: ignore
|
||||
label: 'Settings'
|
||||
options:
|
||||
type: mapping
|
||||
label: 'Options'
|
||||
mapping:
|
||||
label:
|
||||
type: string
|
||||
label: 'label'
|
||||
type:
|
||||
type: string
|
||||
label: 'Type'
|
||||
weight:
|
||||
type: integer
|
||||
label: 'Weight'
|
||||
settings:
|
||||
type: sequence
|
||||
label: 'Settings'
|
||||
sequence:
|
||||
type: string
|
||||
label: 'Settings'
|
||||
selection_handler:
|
||||
type: string
|
||||
label: 'Entity reference selection handler'
|
||||
auto_create:
|
||||
type: boolean
|
||||
label: 'Entity reference selection setting: Auto-create new entities'
|
||||
status:
|
||||
type: boolean
|
||||
label: 'Status'
|
||||
|
||||
migrate.source.md_empty:
|
||||
type: migrate.source.empty
|
||||
label: 'Empty source for migrate_drupal migrations'
|
||||
|
||||
migrate.source.i18n_variable:
|
||||
type: migrate_source_sql
|
||||
label: 'i18n Variable'
|
||||
mapping:
|
||||
variables:
|
||||
type: sequence
|
||||
label: 'Variables'
|
||||
sequence:
|
||||
type: string
|
||||
label: 'Variable'
|
||||
constants:
|
||||
type: mapping
|
||||
label: 'Constants'
|
||||
mapping:
|
||||
entity_type:
|
||||
type: string
|
||||
label: 'Entity type'
|
||||
id:
|
||||
type: string
|
||||
label: 'ID'
|
||||
label:
|
||||
type: label
|
||||
label: 'Label'
|
||||
description:
|
||||
type: text
|
||||
label: 'Description'
|
||||
path:
|
||||
type: string
|
||||
label: 'Path'
|
||||
plugin:
|
||||
type: string
|
||||
label: 'Plugin'
|
||||
status:
|
||||
type: boolean
|
||||
label: 'Status'
|
||||
slash:
|
||||
type: string
|
||||
label: 'Slash'
|
|
@ -5,7 +5,12 @@
|
|||
* Provides migration from other Drupal sites.
|
||||
*/
|
||||
|
||||
use Drupal\Core\Database\DatabaseExceptionWrapper;
|
||||
use Drupal\Core\Routing\RouteMatchInterface;
|
||||
use Drupal\migrate\Exception\RequirementsException;
|
||||
use Drupal\migrate\MigrateExecutable;
|
||||
use Drupal\migrate\MigrateMessage;
|
||||
use Drupal\migrate\Plugin\RequirementsInterface;
|
||||
|
||||
/**
|
||||
* Implements hook_help().
|
||||
|
@ -19,3 +24,53 @@ function migrate_drupal_help($route_name, RouteMatchInterface $route_match) {
|
|||
return $output;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_migration_plugins_alter().
|
||||
*/
|
||||
function migrate_drupal_migration_plugins_alter(&$definitions) {
|
||||
// This is why the deriver can't do this: the 'd6_taxonomy_vocabulary'
|
||||
// definition is not available to the deriver as it is running inside
|
||||
// getDefinitions().
|
||||
if (isset($definitions['d6_taxonomy_vocabulary'])) {
|
||||
$vocabulary_migration_definition = [
|
||||
'source' => [
|
||||
'ignore_map' => TRUE,
|
||||
'plugin' => 'd6_taxonomy_vocabulary',
|
||||
],
|
||||
'destination' => [
|
||||
'plugin' => 'null',
|
||||
],
|
||||
];
|
||||
$vocabulary_migration = \Drupal::service('plugin.manager.migration')->createStubMigration($vocabulary_migration_definition);
|
||||
|
||||
try {
|
||||
$source_plugin = $vocabulary_migration->getSourcePlugin();
|
||||
if ($source_plugin instanceof RequirementsInterface) {
|
||||
$source_plugin->checkRequirements();
|
||||
}
|
||||
$executable = new MigrateExecutable($vocabulary_migration, new MigrateMessage());
|
||||
$process = ['vid' => $definitions['d6_taxonomy_vocabulary']['process']['vid']];
|
||||
foreach ($source_plugin as $row) {
|
||||
$executable->processRow($row, $process);
|
||||
$source_vid = $row->getSourceProperty('vid');
|
||||
$plugin_ids = ['d6_term_node:' . $source_vid, 'd6_term_node_revision:' . $source_vid];
|
||||
foreach ($plugin_ids as $plugin_id) {
|
||||
if (isset($definitions[$plugin_id])) {
|
||||
$definitions[$plugin_id]['process'][$row->getDestinationProperty('vid')] = 'tid';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (RequirementsException $e) {
|
||||
// This code currently runs whenever the definitions are being loaded and
|
||||
// if you have a Drupal 7 source site then the requirements will not be
|
||||
// met for the d6_taxonomy_vocabulary migration.
|
||||
}
|
||||
catch (DatabaseExceptionWrapper $e) {
|
||||
// When the definitions are loaded it is possible the tables will not
|
||||
// exist.
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Annotation\MigrateCckField.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Annotation;
|
||||
|
||||
use Drupal\Component\Annotation\Plugin;
|
||||
|
|
173
core/modules/migrate_drupal/src/MigrationCreationTrait.php
Normal file
173
core/modules/migrate_drupal/src/MigrationCreationTrait.php
Normal file
|
@ -0,0 +1,173 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\migrate_drupal;
|
||||
|
||||
use Drupal\Core\Database\Connection;
|
||||
use Drupal\Core\Database\Database;
|
||||
use Drupal\migrate\Exception\RequirementsException;
|
||||
use Drupal\migrate\Plugin\RequirementsInterface;
|
||||
|
||||
/**
|
||||
* Creates the appropriate migrations for a given source Drupal database.
|
||||
*
|
||||
* @todo https://www.drupal.org/node/2682585 The trait no longer creates
|
||||
* migrations.
|
||||
*/
|
||||
trait MigrationCreationTrait {
|
||||
|
||||
/**
|
||||
* Gets the database connection for the source Drupal database.
|
||||
*
|
||||
* @param array $database
|
||||
* Database array representing the source Drupal database.
|
||||
*
|
||||
* @return \Drupal\Core\Database\Connection
|
||||
* The database connection for the source Drupal database.
|
||||
*/
|
||||
protected function getConnection(array $database) {
|
||||
// Set up the connection.
|
||||
Database::addConnectionInfo('upgrade', 'default', $database);
|
||||
$connection = Database::getConnection('default', 'upgrade');
|
||||
return $connection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the system data from the system table of the source Drupal database.
|
||||
*
|
||||
* @param \Drupal\Core\Database\Connection $connection
|
||||
* Database connection to the source Drupal database.
|
||||
*
|
||||
* @return array
|
||||
* The system data from the system table of the source Drupal database.
|
||||
*/
|
||||
protected function getSystemData(Connection $connection) {
|
||||
$system_data = [];
|
||||
try {
|
||||
$results = $connection->select('system', 's', [
|
||||
'fetch' => \PDO::FETCH_ASSOC,
|
||||
])
|
||||
->fields('s')
|
||||
->execute();
|
||||
foreach ($results as $result) {
|
||||
$system_data[$result['type']][$result['name']] = $result;
|
||||
}
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
// The table might not exist for example in tests.
|
||||
}
|
||||
return $system_data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the necessary state entries for SqlBase::getDatabase() to work.
|
||||
*
|
||||
* The state entities created here have to exist before migration plugin
|
||||
* instances are created so that derivers such as
|
||||
* \Drupal\taxonomy\Plugin\migrate\D6TermNodeDeriver can access the source
|
||||
* database.
|
||||
*
|
||||
* @param array $database
|
||||
* The source database settings.
|
||||
* @param string $drupal_version
|
||||
* The Drupal version.
|
||||
*
|
||||
* @see \Drupal\migrate\Plugin\migrate\source\SqlBase::getDatabase()
|
||||
*/
|
||||
protected function createDatabaseStateSettings(array $database, $drupal_version) {
|
||||
$database_state['key'] = 'upgrade';
|
||||
$database_state['database'] = $database;
|
||||
$database_state_key = 'migrate_drupal_' . $drupal_version;
|
||||
\Drupal::state()->set($database_state_key, $database_state);
|
||||
\Drupal::state()->set('migrate.fallback_state_key', $database_state_key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the migrations for import.
|
||||
*
|
||||
* @param string $database_state_key
|
||||
* The state key.
|
||||
* @param int $drupal_version
|
||||
* The version of Drupal we're getting the migrations for.
|
||||
*
|
||||
* @return \Drupal\migrate\Plugin\MigrationInterface[]
|
||||
* The migrations for import.
|
||||
*/
|
||||
protected function getMigrations($database_state_key, $drupal_version) {
|
||||
$version_tag = 'Drupal ' . $drupal_version;
|
||||
$plugin_manager = \Drupal::service('plugin.manager.migration');
|
||||
/** @var \Drupal\migrate\Plugin\Migration[] $all_migrations */
|
||||
$all_migrations = $plugin_manager->createInstancesByTag($version_tag);
|
||||
$migrations = [];
|
||||
foreach ($all_migrations as $migration) {
|
||||
try {
|
||||
// @todo https://drupal.org/node/2681867 We should be able to validate
|
||||
// the entire migration at this point.
|
||||
$source_plugin = $migration->getSourcePlugin();
|
||||
if ($source_plugin instanceof RequirementsInterface) {
|
||||
$source_plugin->checkRequirements();
|
||||
}
|
||||
$destination_plugin = $migration->getDestinationPlugin();
|
||||
if ($destination_plugin instanceof RequirementsInterface) {
|
||||
$destination_plugin->checkRequirements();
|
||||
}
|
||||
$migrations[] = $migration;
|
||||
}
|
||||
catch (RequirementsException $e) {
|
||||
// Migrations which are not applicable given the source and destination
|
||||
// site configurations (e.g., what modules are enabled) will be silently
|
||||
// ignored.
|
||||
}
|
||||
}
|
||||
|
||||
return $migrations;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines what version of Drupal the source database contains.
|
||||
*
|
||||
* @param \Drupal\Core\Database\Connection $connection
|
||||
* The database connection object.
|
||||
*
|
||||
* @return int|FALSE
|
||||
* An integer representing the major branch of Drupal core (e.g. '6' for
|
||||
* Drupal 6.x), or FALSE if no valid version is matched.
|
||||
*/
|
||||
protected function getLegacyDrupalVersion(Connection $connection) {
|
||||
// Don't assume because a table of that name exists, that it has the columns
|
||||
// we're querying. Catch exceptions and report that the source database is
|
||||
// not Drupal.
|
||||
// Drupal 5/6/7 can be detected by the schema_version in the system table.
|
||||
if ($connection->schema()->tableExists('system')) {
|
||||
try {
|
||||
$version_string = $connection
|
||||
->query('SELECT schema_version FROM {system} WHERE name = :module', [':module' => 'system'])
|
||||
->fetchField();
|
||||
if ($version_string && $version_string[0] == '1') {
|
||||
if ((int) $version_string >= 1000) {
|
||||
$version_string = '5';
|
||||
}
|
||||
else {
|
||||
$version_string = FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (\PDOException $e) {
|
||||
$version_string = FALSE;
|
||||
}
|
||||
}
|
||||
// For Drupal 8 (and we're predicting beyond) the schema version is in the
|
||||
// key_value store.
|
||||
elseif ($connection->schema()->tableExists('key_value')) {
|
||||
$result = $connection
|
||||
->query("SELECT value FROM {key_value} WHERE collection = :system_schema and name = :module", [':system_schema' => 'system.schema', ':module' => 'system'])
|
||||
->fetchField();
|
||||
$version_string = unserialize($result);
|
||||
}
|
||||
else {
|
||||
$version_string = FALSE;
|
||||
}
|
||||
|
||||
return $version_string ? substr($version_string, 0, 1) : FALSE;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,14 +1,9 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\MigrateCckFieldInterface.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin;
|
||||
|
||||
use Drupal\Component\Plugin\PluginInspectionInterface;
|
||||
use Drupal\migrate\Entity\MigrationInterface;
|
||||
use Drupal\migrate\Plugin\MigrationInterface;
|
||||
use Drupal\migrate\Row;
|
||||
|
||||
/**
|
||||
|
@ -19,7 +14,7 @@ interface MigrateCckFieldInterface extends PluginInspectionInterface {
|
|||
/**
|
||||
* Apply any custom processing to the field migration.
|
||||
*
|
||||
* @param \Drupal\migrate\Entity\MigrationInterface $migration
|
||||
* @param \Drupal\migrate\Plugin\MigrationInterface $migration
|
||||
* The migration entity.
|
||||
*/
|
||||
public function processField(MigrationInterface $migration);
|
||||
|
@ -27,7 +22,7 @@ interface MigrateCckFieldInterface extends PluginInspectionInterface {
|
|||
/**
|
||||
* Apply any custom processing to the field instance migration.
|
||||
*
|
||||
* @param \Drupal\migrate\Entity\MigrationInterface $migration
|
||||
* @param \Drupal\migrate\Plugin\MigrationInterface $migration
|
||||
* The migration entity.
|
||||
*/
|
||||
public function processFieldInstance(MigrationInterface $migration);
|
||||
|
@ -35,7 +30,7 @@ interface MigrateCckFieldInterface extends PluginInspectionInterface {
|
|||
/**
|
||||
* Apply any custom processing to the field widget migration.
|
||||
*
|
||||
* @param \Drupal\migrate\Entity\MigrationInterface $migration
|
||||
* @param \Drupal\migrate\Plugin\MigrationInterface $migration
|
||||
* The migration entity.
|
||||
*/
|
||||
public function processFieldWidget(MigrationInterface $migration);
|
||||
|
@ -43,7 +38,7 @@ interface MigrateCckFieldInterface extends PluginInspectionInterface {
|
|||
/**
|
||||
* Apply any custom processing to the field formatter migration.
|
||||
*
|
||||
* @param \Drupal\migrate\Entity\MigrationInterface $migration
|
||||
* @param \Drupal\migrate\Plugin\MigrationInterface $migration
|
||||
* The migration entity.
|
||||
*/
|
||||
public function processFieldFormatter(MigrationInterface $migration);
|
||||
|
@ -69,7 +64,7 @@ interface MigrateCckFieldInterface extends PluginInspectionInterface {
|
|||
/**
|
||||
* Apply any custom processing to the cck bundle migrations.
|
||||
*
|
||||
* @param \Drupal\migrate\Entity\MigrationInterface $migration
|
||||
* @param \Drupal\migrate\Plugin\MigrationInterface $migration
|
||||
* The migration entity.
|
||||
* @param string $field_name
|
||||
* The field name we're processing the value for.
|
||||
|
|
116
core/modules/migrate_drupal/src/Plugin/migrate/CckMigration.php
Normal file
116
core/modules/migrate_drupal/src/Plugin/migrate/CckMigration.php
Normal file
|
@ -0,0 +1,116 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate;
|
||||
|
||||
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
||||
use Drupal\migrate\Exception\RequirementsException;
|
||||
use Drupal\migrate\Plugin\MigrateDestinationPluginManager;
|
||||
use Drupal\migrate\Plugin\MigratePluginManager;
|
||||
use Drupal\migrate\Plugin\Migration;
|
||||
use Drupal\migrate\Plugin\MigrationPluginManagerInterface;
|
||||
use Drupal\migrate\Plugin\RequirementsInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
/**
|
||||
* Migration plugin class for migrations dealing with CCK field values.
|
||||
*/
|
||||
class CckMigration extends Migration implements ContainerFactoryPluginInterface {
|
||||
|
||||
/**
|
||||
* Flag indicating whether the CCK data has been filled already.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $init = FALSE;
|
||||
|
||||
/**
|
||||
* List of cckfield plugin IDs which have already run.
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected $processedFieldTypes = [];
|
||||
|
||||
/**
|
||||
* Already-instantiated cckfield plugins, keyed by ID.
|
||||
*
|
||||
* @var \Drupal\migrate_drupal\Plugin\MigrateCckFieldInterface[]
|
||||
*/
|
||||
protected $cckPluginCache;
|
||||
|
||||
/**
|
||||
* Constructs a CckMigration.
|
||||
*
|
||||
* @param array $configuration
|
||||
* Plugin configuration.
|
||||
* @param string $plugin_id
|
||||
* The plugin ID.
|
||||
* @param mixed $plugin_definition
|
||||
* The plugin definition.
|
||||
* @param \Drupal\migrate\Plugin\MigratePluginManager $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
|
||||
* The source migration plugin manager.
|
||||
* @param \Drupal\migrate\Plugin\MigratePluginManager $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
|
||||
* 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) {
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
|
||||
return new static(
|
||||
$configuration,
|
||||
$plugin_id,
|
||||
$plugin_definition,
|
||||
$container->get('plugin.manager.migrate.cckfield'),
|
||||
$container->get('plugin.manager.migration'),
|
||||
$container->get('plugin.manager.migrate.source'),
|
||||
$container->get('plugin.manager.migrate.process'),
|
||||
$container->get('plugin.manager.migrate.destination'),
|
||||
$container->get('plugin.manager.migrate.id_map')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getProcess() {
|
||||
if (!$this->init) {
|
||||
$this->init = TRUE;
|
||||
$source_plugin = $this->migrationPluginManager->createInstance($this->pluginId)->getSourcePlugin();
|
||||
if ($source_plugin instanceof RequirementsInterface) {
|
||||
try {
|
||||
$source_plugin->checkRequirements();
|
||||
}
|
||||
catch (RequirementsException $e) {
|
||||
// Kill the rest of the method.
|
||||
$source_plugin = [];
|
||||
}
|
||||
}
|
||||
foreach ($source_plugin as $row) {
|
||||
$field_type = $row->getSourceProperty('type');
|
||||
if (!isset($this->processedFieldTypes[$field_type]) && $this->cckPluginManager->hasDefinition($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);
|
||||
}
|
||||
call_user_func([$this->cckPluginCache[$field_type], $this->pluginDefinition['cck_plugin_method']], $this);
|
||||
}
|
||||
}
|
||||
}
|
||||
return parent::getProcess();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,82 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\builder\CckBuilder.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\builder;
|
||||
|
||||
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
||||
use Drupal\migrate\Entity\MigrationInterface;
|
||||
use Drupal\migrate\Plugin\migrate\builder\BuilderBase;
|
||||
use Drupal\migrate\Plugin\MigratePluginManager;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
/**
|
||||
* Base class for builders which leverage cckfield plugins.
|
||||
*/
|
||||
abstract class CckBuilder extends BuilderBase implements ContainerFactoryPluginInterface {
|
||||
|
||||
/**
|
||||
* The cckfield plugin manager.
|
||||
*
|
||||
* @var \Drupal\migrate\Plugin\MigratePluginManager
|
||||
*/
|
||||
protected $cckPluginManager;
|
||||
|
||||
/**
|
||||
* Already-instantiated cckfield plugins, keyed by ID.
|
||||
*
|
||||
* @var \Drupal\migrate_drupal\Plugin\MigrateCckFieldInterface[]
|
||||
*/
|
||||
protected $cckPluginCache = [];
|
||||
|
||||
/**
|
||||
* Constructs a CckBuilder.
|
||||
*
|
||||
* @param array $configuration
|
||||
* Plugin configuration.
|
||||
* @param string $plugin_id
|
||||
* The plugin ID.
|
||||
* @param mixed $plugin_definition
|
||||
* The plugin definition.
|
||||
* @param \Drupal\migrate\Plugin\MigratePluginManager $cck_manager
|
||||
* The cckfield plugin manager.
|
||||
*/
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition, MigratePluginManager $cck_manager) {
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition);
|
||||
$this->cckPluginManager = $cck_manager;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
|
||||
return new static(
|
||||
$configuration,
|
||||
$plugin_id,
|
||||
$plugin_definition,
|
||||
$container->get('plugin.manager.migrate.cckfield')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a cckfield plugin instance.
|
||||
*
|
||||
* @param string $field_type
|
||||
* The field type (plugin ID).
|
||||
* @param \Drupal\migrate\Entity\MigrationInterface|NULL $migration
|
||||
* The migration, if any.
|
||||
*
|
||||
* @return \Drupal\migrate_drupal\Plugin\MigrateCckFieldInterface
|
||||
* The cckfield plugin instance.
|
||||
*/
|
||||
protected function getCckPlugin($field_type, MigrationInterface $migration = NULL) {
|
||||
if (empty($this->cckPluginCache[$field_type])) {
|
||||
$this->cckPluginCache[$field_type] = $this->cckPluginManager->createInstance($field_type, [], $migration);
|
||||
}
|
||||
return $this->cckPluginCache[$field_type];
|
||||
}
|
||||
|
||||
}
|
|
@ -1,68 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\builder\d6\CckMigration.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\builder\d6;
|
||||
|
||||
use Drupal\migrate\Entity\Migration;
|
||||
use Drupal\migrate\Exception\RequirementsException;
|
||||
use Drupal\migrate\Plugin\RequirementsInterface;
|
||||
use Drupal\migrate_drupal\Plugin\migrate\builder\CckBuilder;
|
||||
|
||||
/**
|
||||
* @PluginID("d6_cck_migration")
|
||||
*/
|
||||
class CckMigration extends CckBuilder {
|
||||
|
||||
/**
|
||||
* List of cckfield plugin IDs which have already run.
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected $processedFieldTypes = [];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildMigrations(array $template) {
|
||||
$migration = Migration::create($template);
|
||||
|
||||
$source_plugin = $migration->getSourcePlugin();
|
||||
// The source plugin will throw RequirementsException if CCK is not enabled,
|
||||
// in which case there is nothing else for us to do.
|
||||
if ($source_plugin instanceof RequirementsInterface) {
|
||||
try {
|
||||
$source_plugin->checkRequirements();
|
||||
}
|
||||
catch (RequirementsException $e) {
|
||||
return [$migration];
|
||||
}
|
||||
}
|
||||
|
||||
// Loop through every field that will be migrated.
|
||||
foreach ($source_plugin as $field) {
|
||||
$field_type = $field->getSourceProperty('type');
|
||||
|
||||
// Each field type should only be processed once.
|
||||
if (in_array($field_type, $this->processedFieldTypes)) {
|
||||
continue;
|
||||
}
|
||||
// Only process the current field type if a relevant cckfield plugin
|
||||
// exists.
|
||||
elseif ($this->cckPluginManager->hasDefinition($field_type)) {
|
||||
$this->processedFieldTypes[] = $field_type;
|
||||
// Allow the cckfield plugin to alter the migration as necessary so that
|
||||
// it knows how to handle fields of this type.
|
||||
$this->cckPluginManager
|
||||
->createInstance($field_type, [], $migration)
|
||||
->{$this->configuration['cck_plugin_method']}($migration);
|
||||
}
|
||||
}
|
||||
|
||||
return [$migration];
|
||||
}
|
||||
|
||||
}
|
|
@ -1,14 +1,9 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\cckfield\CckFieldPluginBase.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\cckfield;
|
||||
|
||||
use Drupal\Core\Plugin\PluginBase;
|
||||
use Drupal\migrate\Entity\MigrationInterface;
|
||||
use Drupal\migrate\Plugin\MigrationInterface;
|
||||
use Drupal\migrate\Row;
|
||||
use Drupal\migrate_drupal\Plugin\MigrateCckFieldInterface;
|
||||
|
||||
|
|
|
@ -1,16 +1,11 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\destination\EntityFieldStorageConfig.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\destination;
|
||||
|
||||
use Drupal\Core\Entity\EntityStorageInterface;
|
||||
use Drupal\Core\Field\FieldTypePluginManagerInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Drupal\migrate\Entity\MigrationInterface;
|
||||
use Drupal\migrate\Plugin\MigrationInterface;
|
||||
use Drupal\migrate\Plugin\migrate\destination\EntityFieldStorageConfig as BaseEntityFieldStorageConfig;
|
||||
|
||||
/**
|
||||
|
@ -38,7 +33,7 @@ class EntityFieldStorageConfig extends BaseEntityFieldStorageConfig {
|
|||
* The plugin_id for the plugin instance.
|
||||
* @param mixed $plugin_definition
|
||||
* The plugin implementation definition.
|
||||
* @param MigrationInterface $migration
|
||||
* @param \Drupal\migrate\Plugin\MigrationInterface $migration
|
||||
* The migration.
|
||||
* @param EntityStorageInterface $storage
|
||||
* The storage for this entity type.
|
||||
|
@ -75,7 +70,7 @@ class EntityFieldStorageConfig extends BaseEntityFieldStorageConfig {
|
|||
$this->dependencies = parent::calculateDependencies();
|
||||
// Add a dependency on the module that provides the field type using the
|
||||
// source plugin configuration.
|
||||
$source_configuration = $this->migration->get('source');
|
||||
$source_configuration = $this->migration->getSourceConfiguration();
|
||||
if (isset($source_configuration['constants']['type'])) {
|
||||
$field_type = $this->fieldTypePluginManager->getDefinition($source_configuration['constants']['type']);
|
||||
$this->addDependency('module', $field_type['provider']);
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\source;
|
||||
|
||||
use Drupal\Component\Plugin\DependentPluginInterface;
|
||||
|
@ -12,7 +7,7 @@ use Drupal\Core\Entity\DependencyTrait;
|
|||
use Drupal\Core\Entity\EntityManagerInterface;
|
||||
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
||||
use Drupal\Core\State\StateInterface;
|
||||
use Drupal\migrate\Entity\MigrationInterface;
|
||||
use Drupal\migrate\Plugin\MigrationInterface;
|
||||
use Drupal\migrate\Exception\RequirementsException;
|
||||
use Drupal\migrate\Plugin\migrate\source\SqlBase;
|
||||
use Drupal\migrate\Plugin\RequirementsInterface;
|
||||
|
|
|
@ -1,16 +1,11 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\source\EmptySource.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\source;
|
||||
|
||||
use Drupal\Component\Plugin\DependentPluginInterface;
|
||||
use Drupal\Core\Entity\DependencyTrait;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Drupal\migrate\Entity\MigrationInterface;
|
||||
use Drupal\migrate\Plugin\MigrationInterface;
|
||||
use Drupal\migrate\Plugin\migrate\source\EmptySource as BaseEmptySource;
|
||||
use Drupal\Core\Entity\EntityManagerInterface;
|
||||
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
||||
|
|
|
@ -1,15 +1,10 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\source\Variable.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\source;
|
||||
|
||||
use Drupal\Core\Entity\EntityManagerInterface;
|
||||
use Drupal\Core\State\StateInterface;
|
||||
use Drupal\migrate\Entity\MigrationInterface;
|
||||
use Drupal\migrate\Plugin\MigrationInterface;
|
||||
|
||||
/**
|
||||
* Drupal variable source from database.
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\source\VariableMultiRow.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\source;
|
||||
|
||||
use Drupal\migrate\Row;
|
||||
|
|
|
@ -1,15 +1,10 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\source\d6\i18nVariable.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\Core\Entity\EntityManagerInterface;
|
||||
use Drupal\Core\State\StateInterface;
|
||||
use Drupal\migrate\Entity\MigrationInterface;
|
||||
use Drupal\migrate\Plugin\MigrationInterface;
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\source\d7\FieldableEntity.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\source\d7;
|
||||
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
|
|
|
@ -1,76 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Tests\MigrateDrupalTestBase.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Tests;
|
||||
|
||||
use Drupal\Core\Database\Database;
|
||||
use Drupal\migrate\Tests\MigrateTestBase;
|
||||
use Drupal\Component\Plugin\Exception\PluginNotFoundException;
|
||||
|
||||
/**
|
||||
* Base class for Drupal migration tests.
|
||||
*/
|
||||
abstract class MigrateDrupalTestBase extends MigrateTestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('system', 'user', 'field', 'migrate_drupal', 'options', 'file');
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->installEntitySchema('user');
|
||||
$this->installConfig(['migrate_drupal', 'system']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads a database fixture into the source database connection.
|
||||
*
|
||||
* @param string $path
|
||||
* Path to the dump file.
|
||||
*/
|
||||
protected function loadFixture($path) {
|
||||
$default_db = Database::getConnection()->getKey();
|
||||
Database::setActiveConnection($this->sourceDatabase->getKey());
|
||||
|
||||
if (substr($path, -3) == '.gz') {
|
||||
$path = 'compress.zlib://' . $path;
|
||||
}
|
||||
require $path;
|
||||
|
||||
Database::setActiveConnection($default_db);
|
||||
}
|
||||
|
||||
/**
|
||||
* Turn all the migration templates for the specified drupal version into
|
||||
* real migration entities so we can test them.
|
||||
*
|
||||
* @param string $version
|
||||
* Drupal version as provided in migration_tags - e.g., 'Drupal 6'.
|
||||
*/
|
||||
protected function installMigrations($version) {
|
||||
$migration_templates = \Drupal::service('migrate.template_storage')->findTemplatesByTag($version);
|
||||
$migrations = \Drupal::service('migrate.migration_builder')->createMigrations($migration_templates);
|
||||
foreach ($migrations as $migration) {
|
||||
try {
|
||||
$migration->save();
|
||||
}
|
||||
catch (PluginNotFoundException $e) {
|
||||
// Migrations requiring modules not enabled will throw an exception.
|
||||
// Ignoring this exception is equivalent to placing config in the
|
||||
// optional subdirectory - the migrations we require for the test will
|
||||
// be successfully saved.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,12 +1,7 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Tests\StubTestTrait.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Tests;
|
||||
use Drupal\migrate\Entity\Migration;
|
||||
|
||||
use Drupal\migrate\Row;
|
||||
|
||||
/**
|
||||
|
@ -45,14 +40,13 @@ trait StubTestTrait {
|
|||
*/
|
||||
protected function createStub($entity_type_id) {
|
||||
// Create a dummy migration to pass to the destination plugin.
|
||||
$config = [
|
||||
'id' => 'dummy',
|
||||
$definition = [
|
||||
'migration_tags' => ['Stub test'],
|
||||
'source' => ['plugin' => 'empty'],
|
||||
'process' => [],
|
||||
'destination' => ['plugin' => 'entity:' . $entity_type_id],
|
||||
];
|
||||
$migration = Migration::create($config);
|
||||
$migration = \Drupal::service('plugin.manager.migration')->createStubMigration($definition);
|
||||
$destination_plugin = $migration->getDestinationPlugin(TRUE);
|
||||
$stub_row = new Row([], [], TRUE);
|
||||
$destination_ids = $destination_plugin->import($stub_row);
|
||||
|
|
|
@ -1,51 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Tests\d6\CckMigrationBuilderTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Tests\d6;
|
||||
|
||||
use Drupal\Core\Database\Database;
|
||||
|
||||
/**
|
||||
* @group migrate_drupal
|
||||
*/
|
||||
class CckMigrationBuilderTest extends MigrateDrupal6TestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['field'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$database = Database::getConnection('default', 'migrate');
|
||||
$database
|
||||
->update('system')
|
||||
->fields(array('status' => 0))
|
||||
->condition('name', 'content')
|
||||
->condition('type', 'module')
|
||||
->execute();
|
||||
$database->schema()->dropTable('content_node_field');
|
||||
$database->schema()->dropTable('content_node_field_instance');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that the CckMigration builder performs a requirements check on the
|
||||
* source plugin.
|
||||
*/
|
||||
public function testRequirementCheck() {
|
||||
$template = \Drupal::service('migrate.template_storage')
|
||||
->getTemplateByName('d6_field');
|
||||
// Without the requirements check, this will throw a \PDOException because
|
||||
// the CCK tables do not exist.
|
||||
\Drupal::service('migrate.migration_builder')->createMigrations([$template]);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Tests\d7\MigrateDrupal7TestBase.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Tests\d7;
|
||||
|
||||
use Drupal\migrate_drupal\Tests\MigrateDrupalTestBase;
|
||||
|
||||
/**
|
||||
* Base class for Drupal 7 migration tests.
|
||||
*/
|
||||
abstract class MigrateDrupal7TestBase extends MigrateDrupalTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->loadFixture(__DIR__ . '/../../../tests/fixtures/drupal7.php');
|
||||
$this->installMigrations('Drupal 7');
|
||||
}
|
||||
|
||||
}
|
13987
core/modules/migrate_drupal/tests/fixtures/drupal6.php
vendored
13987
core/modules/migrate_drupal/tests/fixtures/drupal6.php
vendored
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\migrate_drupal\Kernel;
|
||||
|
||||
use Drupal\Core\Database\Database;
|
||||
use Drupal\Tests\migrate\Kernel\MigrateTestBase;
|
||||
|
||||
/**
|
||||
* Base class for Drupal migration tests.
|
||||
*/
|
||||
abstract class MigrateDrupalTestBase extends MigrateTestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('system', 'user', 'field', 'migrate_drupal', 'options', 'file');
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->installEntitySchema('user');
|
||||
$this->installConfig(['migrate_drupal', 'system']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads a database fixture into the source database connection.
|
||||
*
|
||||
* @param string $path
|
||||
* Path to the dump file.
|
||||
*/
|
||||
protected function loadFixture($path) {
|
||||
$default_db = Database::getConnection()->getKey();
|
||||
Database::setActiveConnection($this->sourceDatabase->getKey());
|
||||
|
||||
if (substr($path, -3) == '.gz') {
|
||||
$path = 'compress.zlib://' . $path;
|
||||
}
|
||||
require $path;
|
||||
|
||||
Database::setActiveConnection($default_db);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,11 +1,6 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Tests\d6\EntityContentBaseTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Tests\d6;
|
||||
namespace Drupal\Tests\migrate_drupal\Kernel\d6;
|
||||
|
||||
use Drupal\field\Entity\FieldConfig;
|
||||
use Drupal\field\Entity\FieldStorageConfig;
|
|
@ -1,14 +1,8 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase.
|
||||
*/
|
||||
namespace Drupal\Tests\migrate_drupal\Kernel\d6;
|
||||
|
||||
namespace Drupal\migrate_drupal\Tests\d6;
|
||||
|
||||
use Drupal\migrate\Entity\Migration;
|
||||
use Drupal\migrate_drupal\Tests\MigrateDrupalTestBase;
|
||||
use Drupal\Tests\migrate_drupal\Kernel\MigrateDrupalTestBase;
|
||||
|
||||
/**
|
||||
* Base class for Drupal 6 migration tests.
|
||||
|
@ -34,8 +28,7 @@ abstract class MigrateDrupal6TestBase extends MigrateDrupalTestBase {
|
|||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->loadFixture( __DIR__ . '/../../../tests/fixtures/drupal6.php');
|
||||
$this->installMigrations('Drupal 6');
|
||||
$this->loadFixture( __DIR__ . '/../../../fixtures/drupal6.php');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -58,13 +51,6 @@ abstract class MigrateDrupal6TestBase extends MigrateDrupalTestBase {
|
|||
'user_picture_entity_form_display',
|
||||
]);
|
||||
}
|
||||
else {
|
||||
// These are optional dependencies of d6_user, but we don't need them if
|
||||
// we're not migrating user pictures.
|
||||
Migration::load('d6_user_picture_file')->delete();
|
||||
Migration::load('user_picture_entity_display')->delete();
|
||||
Migration::load('user_picture_entity_form_display')->delete();
|
||||
}
|
||||
|
||||
$this->executeMigration('d6_user');
|
||||
}
|
||||
|
@ -104,10 +90,10 @@ abstract class MigrateDrupal6TestBase extends MigrateDrupalTestBase {
|
|||
$this->migrateFields();
|
||||
|
||||
$this->installEntitySchema('node');
|
||||
$this->executeMigrations(['d6_node_settings', 'd6_node:*']);
|
||||
$this->executeMigrations(['d6_node_settings', 'd6_node']);
|
||||
|
||||
if ($include_revisions) {
|
||||
$this->executeMigrations(['d6_node_revision:*']);
|
||||
$this->executeMigrations(['d6_node_revision']);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\migrate_drupal\Kernel\d7;
|
||||
|
||||
use Drupal\Tests\migrate_drupal\Kernel\MigrateDrupalTestBase;
|
||||
|
||||
/**
|
||||
* Base class for Drupal 7 migration tests.
|
||||
*/
|
||||
abstract class MigrateDrupal7TestBase extends MigrateDrupalTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->loadFixture(__DIR__ . '/../../../fixtures/drupal7.php');
|
||||
}
|
||||
|
||||
}
|
|
@ -1,16 +1,10 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Tests\dependencies\MigrateDependenciesTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Tests\dependencies;
|
||||
namespace Drupal\Tests\migrate_drupal\Kernel\dependencies;
|
||||
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
use Drupal\migrate\Entity\Migration;
|
||||
use Drupal\migrate\MigrateExecutable;
|
||||
use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
|
||||
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
|
||||
|
||||
/**
|
||||
* Ensure the consistency among the dependencies for migrate.
|
||||
|
@ -28,24 +22,24 @@ class MigrateDependenciesTest extends MigrateDrupal6TestBase {
|
|||
* Tests that the order is correct when loading several migrations.
|
||||
*/
|
||||
public function testMigrateDependenciesOrder() {
|
||||
$migration_items = array('d6_comment', 'd6_filter_format', 'd6_node__page');
|
||||
$migrations = Migration::loadMultiple($migration_items);
|
||||
$expected_order = array('d6_filter_format', 'd6_node__page', 'd6_comment');
|
||||
$migration_items = array('d6_comment', 'd6_filter_format', 'd6_node:page');
|
||||
$migrations = $this->container->get('plugin.manager.migration')->createInstances($migration_items);
|
||||
$expected_order = array('d6_filter_format', 'd6_node:page', 'd6_comment');
|
||||
$this->assertIdentical(array_keys($migrations), $expected_order);
|
||||
$expected_requirements = array(
|
||||
// d6_comment depends on d6_node:*, which the storage controller expands
|
||||
// into every variant of d6_node created by the MigrationBuilder.
|
||||
'd6_node__article',
|
||||
'd6_node__company',
|
||||
'd6_node__employee',
|
||||
'd6_node__event',
|
||||
'd6_node__page',
|
||||
'd6_node__sponsor',
|
||||
'd6_node__story',
|
||||
'd6_node__test_event',
|
||||
'd6_node__test_page',
|
||||
'd6_node__test_planet',
|
||||
'd6_node__test_story',
|
||||
// d6_comment depends on d6_node:*, which the deriver expands into every
|
||||
// variant of d6_node.
|
||||
'd6_node:article',
|
||||
'd6_node:company',
|
||||
'd6_node:employee',
|
||||
'd6_node:event',
|
||||
'd6_node:page',
|
||||
'd6_node:sponsor',
|
||||
'd6_node:story',
|
||||
'd6_node:test_event',
|
||||
'd6_node:test_page',
|
||||
'd6_node:test_planet',
|
||||
'd6_node:test_story',
|
||||
'd6_node_type',
|
||||
'd6_node_settings',
|
||||
'd6_filter_format',
|
||||
|
@ -67,8 +61,8 @@ class MigrateDependenciesTest extends MigrateDrupal6TestBase {
|
|||
* Tests dependencies on the migration of aggregator feeds & items.
|
||||
*/
|
||||
public function testAggregatorMigrateDependencies() {
|
||||
/** @var \Drupal\migrate\entity\Migration $migration */
|
||||
$migration = Migration::load('d6_aggregator_item');
|
||||
/** @var \Drupal\migrate\Plugin\Migration $migration */
|
||||
$migration = $this->getMigration('d6_aggregator_item');
|
||||
$executable = new MigrateExecutable($migration, $this);
|
||||
$this->startCollectingMessages();
|
||||
$executable->import();
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\migrate_drupal\Unit\source\VariableMultiRowSourceWithHighwaterTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\migrate_drupal\Unit\source;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\migrate_drupal\Unit\source\VariableMultiRowTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\migrate_drupal\Unit\source;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\migrate_drupal\Unit\source\VariableMultiRowTestBase.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\migrate_drupal\Unit\source;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\migrate_drupal\Unit\source\VariableTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\migrate_drupal\Unit\source;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\migrate_drupal\Unit\source\d6\i18nVariableTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\migrate_drupal\Unit\source\d6;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
|
|
Reference in a new issue