summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.txt27
-rw-r--r--includes/base.inc56
-rw-r--r--includes/migration.inc4
-rw-r--r--migrate.drush.inc58
-rwxr-xr-xmigrate.install45
-rwxr-xr-xmigrate.module54
-rw-r--r--migrate_example/beer.inc12
-rw-r--r--migrate_example/wine.inc62
-rw-r--r--migrate_ui/migrate_ui.module3
-rw-r--r--tests/plugins/destinations/comment.test18
-rw-r--r--tests/plugins/destinations/node.test20
-rw-r--r--tests/plugins/destinations/term.test4
-rw-r--r--tests/plugins/destinations/user.test2
-rw-r--r--tests/plugins/sources/xml.test8
14 files changed, 245 insertions, 128 deletions
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index d19f8dc..ac931d6 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -2,15 +2,40 @@
Migrate 2.0 Beta 3
==================
+
Features and enhancements
+
+- #989200 - Support "dynamic" migrations. Changes to be aware of:
+ All modules implementing migration classes must now implement hook_migrate_api()
+ (see migrate_migrate_api() for an example).
+ Dependencies and sourceMigrations must now be expressed in terms of
+ machine name rather than class name.
+ MigrationBase::getInstance now takes a machine name rather than a class name.
+ Migration class names are no longer required to end in 'Migration'.
+
+Add logging of fetch queries and dqp() function to translate DBTNG query object into full SQL.
Inherit default settings for promote, sticky, status, status from content type
configuration. Already done in D7.
Add arguments method for MigrateTermNodeHandler class
+Add dedupe() method for a field mapping.
+maintainStatistics business removed from comment import.
+Default comments to published status
Bug fixes
-- #990960- Initialize fields array for profiles
+
+Avoid notice in user.inc
+- #990960 - Initialize fields array for profiles
+- #839770 - Notice: Undefined property: stdClass:: in forum_node_presave() when
+ generating forum nodes.
- #984294 - Make migrate dashbard a local task.
needs_update => needs-update to match drush conventions.
+Inherit default settings for promote, sticky, status, status from content type
+ configuration. Already done in D7.
+- #898622 - Undefined variable in MigrateDestinationNode::import()
+- #839770 - Notice: Undefined property: stdClass:: in forum_node_presave() when
+ generating forum nodes.
+- #990960 - Initialize fields array for profiles
+- #983968 - Bogus settings of ->uid
Migrate 2.0 Beta 2
==================
diff --git a/includes/base.inc b/includes/base.inc
index 6d80f6c..96b5aaf 100644
--- a/includes/base.inc
+++ b/includes/base.inc
@@ -243,10 +243,23 @@ abstract class MigrationBase {
* General initialization of a MigrationBase object.
*/
public function __construct() {
- // Construct the machine name by stripping Migration from our class name
- $class = get_class($this);
- $this->machineName = substr($class, 0, strlen($class) - strlen('Migration'));
-
+ $this->machineName = $this->generateMachineName();
+
+ // Make sure migrate_status record exists
+ $class_name = db_select('migrate_status', 'ms')
+ ->fields('ms', array('class_name'))
+ ->condition('machine_name', $this->machineName)
+ ->execute()
+ ->fetchField();
+ if (!$class_name) {
+ db_insert('migrate_status')
+ ->fields(array(
+ 'machine_name' => $this->machineName,
+ 'class_name' => get_class($this),
+ 'arguments' => serialize($arguments),
+ ))
+ ->execute();
+ }
// Record the memory limit in bytes
$limit = trim(ini_get('memory_limit'));
$last = strtolower($limit[strlen($limit)-1]);
@@ -277,15 +290,32 @@ abstract class MigrationBase {
}
/**
- * Return the instance of the given class.
+ * By default, construct the machine name by stripping Migration from our class name
*/
- static public function getInstance($class_name) {
- // Otherwise might miss cache hit on case difference
- $class_name = strtolower($class_name);
- if (!isset(self::$migrations[$class_name])) {
- self::$migrations[$class_name] = new $class_name;
+ protected function generateMachineName() {
+ $class = get_class($this);
+ return substr($class, 0, strlen($class) - strlen('Migration'));
+ }
+
+ /**
+ * Return the single instance of the given class.
+ *
+ * @param string $machine_name
+ */
+ static public function getInstance($machine_name) {
+ $row = db_select('migrate_status', 'ms')
+ ->fields('ms', array('class_name', 'arguments'))
+ ->condition('machine_name', $machine_name)
+ ->execute()
+ ->fetchObject();
+ if ($row) {
+ $class_name = $row->class_name;
+ $arguments = unserialize($row->arguments);
+ }
+ else {
+ $class_name = $machine_name . 'Migration';
+ $arguments = array();
}
- return self::$migrations[$class_name];
}
/**
@@ -517,7 +547,7 @@ abstract class MigrationBase {
$this->status = $newStatus;
db_merge('migrate_status')
->key(array('machine_name' => $this->machineName))
- ->fields(array('status' => $newStatus))
+ ->fields(array('class_name' => get_class($this), 'status' => $newStatus))
->execute();
// Set an error handler for imports
@@ -553,7 +583,7 @@ abstract class MigrationBase {
}
if ($this->processing) {
$this->status = MigrationBase::STATUS_IDLE;
- $fields = array('status' => MigrationBase::STATUS_IDLE);
+ $fields = array('class_name' => get_class($this), 'status' => MigrationBase::STATUS_IDLE);
db_merge('migrate_status')
->key(array('machine_name' => $this->machineName))
->fields($fields)
diff --git a/includes/migration.inc b/includes/migration.inc
index f57a681..b7f0518 100644
--- a/includes/migration.inc
+++ b/includes/migration.inc
@@ -117,8 +117,8 @@ abstract class Migration extends MigrationBase {
/**
* General initialization of a Migration object.
*/
- public function __construct() {
- parent::__construct();
+ public function __construct(array $arguments = array()) {
+ parent::__construct($arguments);
}
////////////////////////////////////////////////////////////////////
diff --git a/migrate.drush.inc b/migrate.drush.inc
index 36b0cfb..fd710e1 100644
--- a/migrate.drush.inc
+++ b/migrate.drush.inc
@@ -223,7 +223,7 @@ function drush_migrate_status($name = NULL) {
// Validate input and load Migration(s).
if ($name) {
- if ($migration = MigrationBase::getInstance($name . 'Migration')) {
+ if ($migration = MigrationBase::getInstance($name)) {
$migrations = array($migration);
}
else {
@@ -293,26 +293,15 @@ function drush_migrate_fields_destination() {
$args = func_get_args();
$machine_name = array_shift($args);
// First, see if it matches a migration class
- $class_name = $machine_name . 'Migration';
- if (class_exists($class_name)) {
- $migration = MigrationBase::getInstance($class_name);
+ $migration = MigrationBase::getInstance($class_name);
+ if ($migration) {
$destination = $migration->getDestination();
}
else {
- // No match, try a destination class
- // TODO: Client implementations won't follow this naming convention - look
- // for subclasses of MigrateDestinationEntity and match entityType?
- $class_name = 'MigrateDestination' . $machine_name;
- if (class_exists($class_name)) {
- $bundle = array_shift($args);
- $destination = new $class_name($bundle);
- }
- else {
- drush_log(dt('No class found matching !machine_name',
- array('!machine_name' => $machine_name)),
- 'error');
- return;
- }
+ drush_log(dt('No migration found matching !machine_name',
+ array('!machine_name' => $machine_name)),
+ 'error');
+ return;
}
if (method_exists($destination, fields)) {
$table = array();
@@ -368,12 +357,8 @@ function drush_migrate_descriptions() {
try {
$args = func_get_args();
$machine_name = array_shift($args);
- // See if it matches a migration class
- $class_name = $machine_name . 'Migration';
- if (class_exists($class_name)) {
- $migration = MigrationBase::getInstance($class_name);
- }
- else {
+ $migration = MigrationBase::getInstance($machine_name);
+ if (!$migration) {
return drush_set_error(dt('No class found matching !machine_name',
array('!machine_name' => $machine_name)));
}
@@ -496,11 +481,12 @@ function drush_migrate_rollback($args = NULL) {
function drush_migrate_get_migrations($args) {
static $migration_objects;
+ $migration_objects = migrate_migrations();
+
if ($start = drush_get_option('all')) {
// Handle custom first migration when --all=foo is supplied.
$seen = $start === TRUE ? TRUE : FALSE;
- $migration_objects = migrate_migrations();
foreach ($migration_objects as $name => $migration) {
if (!$seen && (strtolower($start) . 'migration' == strtolower($name))) {
// We found our starting migration. $seen is always TRUE now.
@@ -513,15 +499,14 @@ function drush_migrate_get_migrations($args) {
}
}
else {
- if (!isset($migration_objects)) {
- foreach (explode(',', $args) as $name) {
- $class_name = $name . 'Migration';
- $migration = MigrationBase::getInstance($class_name);
- if ($migration->getEnabled()) {
- $migration_objects[$name] = $migration;
- }
+ $named_migrations = array();
+ foreach (explode(',', $args) as $name) {
+ $migration = $migration_objects[$name];
+ if ($migration->getEnabled()) {
+ $named_migrations[$name] = $migration;
}
}
+ $migration_objects = $named_migrations;
}
return $migration_objects;
}
@@ -561,10 +546,15 @@ function drush_migrate_validate_common($args) {
if (empty($args)) {
return drush_set_error(NULL, dt('You must specify either a migration name or the -all option'));
}
- $machine_names = explode(',', strtolower($args));
+ $machine_names = explode(',', $args);
foreach ($machine_names as $machine_name) {
- if (!class_exists($machine_name . 'Migration')) {
+ $class_name = db_select('migrate_status', 'ms')
+ ->fields('ms', array('class_name'))
+ ->condition('machine_name', $machine_name)
+ ->execute()
+ ->fetchField();
+ if (!$class_name || !class_exists($class_name)) {
drush_set_error(dt('Unrecognized migration: !name', array('!name' => $machine_name)));
}
}
diff --git a/migrate.install b/migrate.install
index d4acb4c..6f7aee0 100755
--- a/migrate.install
+++ b/migrate.install
@@ -23,6 +23,12 @@ function migrate_schema_status() {
'not null' => TRUE,
'description' => 'Unique machine name for migration',
),
+ 'class_name' => array(
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'not null' => TRUE,
+ 'description' => 'Name of class to instantiate for this migration',
+ ),
'status' => array(
'type' => 'int',
'size' => 'tiny',
@@ -38,6 +44,13 @@ function migrate_schema_status() {
'default' => '',
'description' => 'Highwater mark for detecting updated content',
),
+ 'arguments' => array(
+ 'type' => 'blob',
+ 'not null' => FALSE,
+ 'size' => 'big',
+ 'serialize' => TRUE,
+ 'description' => 'A serialized array of arguments to the migration constructor',
+ ),
),
'primary key' => array('machine_name'),
);
@@ -194,3 +207,35 @@ function migrate_update_6002() {
db_drop_field($ret, 'migrate_status', 'lastimportedtime');
return $ret;
}
+
+/**
+ * Add and populate class_name field, and add arguments field. Any existing
+ * migration code using dependencies or sourceMigration() must be changed!
+ * See CHANGELOG.txt.
+ */
+function migrate_update_6003() {
+ $ret = array();
+ db_add_field($ret, 'migrate_status', 'class_name', array(
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'not null' => TRUE,
+ 'default' => '',
+ 'description' => 'Name of class to instantiate for this migration',
+ )
+ );
+
+ db_query("UPDATE {migrate_status}
+ SET class_name = CONCAT(machine_name, 'Migration')
+ ");
+
+ db_add_field($ret, 'migrate_status', 'arguments', array(
+ 'type' => 'blob',
+ 'not null' => FALSE,
+ 'size' => 'big',
+ 'serialize' => TRUE,
+ 'description' => 'A serialized array of arguments to the migration constructor',
+ )
+ );
+
+ return $ret;
+}
diff --git a/migrate.module b/migrate.module
index 472c77c..e0db528 100755
--- a/migrate.module
+++ b/migrate.module
@@ -29,7 +29,21 @@ require_once drupal_get_path('module', 'migrate') . '/includes/d7.inc';
* Array of migration objects, keyed by the class name.
*/
function migrate_migrations($refresh = FALSE) {
- return _migrate_class_list('%Migration', 'MigrationBase', $refresh);
+ // First, get a list of all Migration classes as a starting point. Note
+ // we set up PHP errors to be handled by throwing exceptions, so we can deal
+ // with migrations that have parameters and thus can't be instantiated here.
+// $error_handler = set_error_handler('migrate_exception_error_handler');
+ $migrations = _migrate_class_list('%Migration', 'MigrationBase', $refresh);
+// set_error_handler($error_handler);
+
+ // Then, let modules add instances of dynamic migrations, and perhaps remove
+ // the classes underlying them
+ drupal_alter('migrations', $migrations);
+ return $migrations;
+}
+
+function migrate_exception_error_handler($errno, $errstr, $errfile, $errline ) {
+ throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
}
/**
@@ -142,27 +156,39 @@ function _migrate_class_list($class_pattern, $parent_class, $refresh = FALSE) {
// Validate it's an implemented subclass of the parent class
$class = new ReflectionClass($record->name);
if (!$class->isAbstract() && $class->isSubclassOf($parent_class)) {
- if ($parent_class == 'Migration') {
- $object = Migration::getInstance($record->name);
+ if ($parent_class == 'MigrationBase') {
+ $machine_name = substr($record->name, 0, strlen($record->name) - strlen('Migration'));
+ $object = Migration::getInstance($machine_name);
}
else {
- $object = new $record->name;
- }
- $dependencies = $object->getDependencies();
- if (count($dependencies) > 0) {
- // Set classes with dependencies aside for reordering
- $dependent_classes[$record->name] = $object;
- $required_classes += $dependencies;
+ // If the constructor has required parameters, this may fail. We will
+ // silently ignore - it is up to the implementor of such a class to
+ // instantiate it in hook_migrations_alter().
+ try {
+ $object = new $record->name;
+ }
+ catch (Exception $e) {
+ }
}
- else {
- // No dependencies, just add
- $class_lists[$class_pattern][$record->name] = $object;
+ if (isset($object)) {
+ $dependencies = $object->getDependencies();
+ if (count($dependencies) > 0) {
+ // Set classes with dependencies aside for reordering
+ $dependent_classes[$record->name] = $object;
+ $required_classes += $dependencies;
+ }
+ else {
+ // No dependencies, just add
+ $class_lists[$class_pattern][$record->name] = $object;
+ }
}
}
}
// Validate that each depended-on class at least exists
foreach ($required_classes as $class_name) {
+ // Dependencies expressed as machine names, restore class name
+ $class_name .= 'Migration';
if ((!isset($dependent_classes[$class_name])) && !isset($class_lists[$class_pattern][$class_name])) {
throw new MigrateException(t('Dependency on non-existent class !class - make sure ' .
'you have added the file defining !class to the .info file.',
@@ -185,6 +211,8 @@ function _migrate_class_list($class_pattern, $parent_class, $refresh = FALSE) {
// Scan all the dependencies for this class and make sure they're all
// in the final list
foreach ($object->getDependencies() as $dependency) {
+ // Convert machine name to class name
+ $dependency .= 'Migration';
if (!isset($class_lists[$class_pattern][$dependency])) {
$ready = FALSE;
break;
diff --git a/migrate_example/beer.inc b/migrate_example/beer.inc
index f2bb007..be70cea 100644
--- a/migrate_example/beer.inc
+++ b/migrate_example/beer.inc
@@ -256,7 +256,7 @@ class BeerNodeMigration extends BasicExampleMigration {
// You may optionally declare dependencies for your migration - other migrations
// which should run first. In this case, terms assigned to our nodes and
// the authors of the nodes should be migrated before the nodes themselves.
- $this->dependencies = array('BeerTermMigration', 'BeerUserMigration');
+ $this->dependencies = array('BeerTerm', 'BeerUser');
$this->map = new MigrateSQLMap($this->machineName,
array(
@@ -309,7 +309,7 @@ class BeerNodeMigration extends BasicExampleMigration {
// find a corresponding uid for the aid, the owner will be the administrative
// account.
$this->addFieldMapping('uid', 'aid')
- ->sourceMigration('BeerUserMigration')
+ ->sourceMigration('BeerUser')
->defaultValue(1);
// This is a multi-value text field
@@ -357,7 +357,7 @@ class BeerCommentMigration extends BasicExampleMigration {
public function __construct() {
parent::__construct();
$this->description = 'Comments about beers';
- $this->dependencies = array('BeerUserMigration', 'BeerNodeMigration');
+ $this->dependencies = array('BeerUser', 'BeerNode');
$this->map = new MigrateSQLMap($this->machineName,
array('cid' => array(
'type' => 'int',
@@ -381,13 +381,13 @@ class BeerCommentMigration extends BasicExampleMigration {
// Map the incoming beer ID to the resulting Drupal nid
$this->addFieldMapping('nid', 'bid')
- ->sourceMigration('BeerNodeMigration');
+ ->sourceMigration('BeerNode');
$this->addFieldMapping('uid', 'aid')
- ->sourceMigration('BeerUserMigration')
+ ->sourceMigration('BeerUser')
->defaultValue(0);
$this->addFieldMapping('pid', 'cid_parent')
- ->sourceMigration('BeerCommentMigration')
+ ->sourceMigration('BeerComment')
->description('Parent comment.');
$this->addFieldMapping('comment', 'body');
diff --git a/migrate_example/wine.inc b/migrate_example/wine.inc
index 7d09acd..c4866e3 100644
--- a/migrate_example/wine.inc
+++ b/migrate_example/wine.inc
@@ -53,7 +53,7 @@ class WinePrepMigration extends MigrationBase {
// case, we want the wine migrations to appear after the beer migrations -
// without this line, they would be intermingled due to their lack of
// (formal) interdependencies.
- $this->softDependencies = array('BeerCommentMigration');
+ $this->softDependencies = array('BeerComment');
}
// Define isComplete(), returning a boolean, to indicate whether dependent
// migrations may proceed
@@ -87,7 +87,7 @@ abstract class WineTermMigration extends AdvancedExampleMigration {
public function __construct($type, $vocabulary_name, $description) {
parent::__construct();
$this->description = $description;
- $this->dependencies = array('WinePrepMigration');
+ $this->dependencies = array('WinePrep');
$this->map = new MigrateSQLMap($this->machineName,
array(
'categoryid' => array('type' => 'int',
@@ -148,7 +148,7 @@ class WineUserMigration extends AdvancedExampleMigration {
public function __construct() {
parent::__construct();
$this->description = t('Wine Drinkers of the world');
- $this->dependencies = array('WinePrepMigration');
+ $this->dependencies = array('WinePrep');
$this->map = new MigrateSQLMap($this->machineName,
array('accountid' => array(
'type' => 'int',
@@ -199,7 +199,7 @@ class WineProducerMigration extends AdvancedExampleMigration {
public function __construct() {
parent::__construct();
$this->description = t('Wine producers of the world');
- $this->dependencies = array('WineRegionMigration', 'WineUserMigration');
+ $this->dependencies = array('WineRegion', 'WineUser');
$this->map = new MigrateSQLMap($this->machineName,
array(
@@ -227,10 +227,10 @@ class WineProducerMigration extends AdvancedExampleMigration {
$this->addFieldMapping('title', 'name')
->description(t('Mapping producer name in source to node title'));
$this->addFieldMapping('uid', 'accountid')
- ->sourceMigration('WineUserMigration')
+ ->sourceMigration('WineUser')
->defaultValue(1);
$this->addFieldMapping('Migrate Example Wine Regions', 'region')
- ->sourceMigration('WineRegionMigration')
+ ->sourceMigration('WineRegion')
->arguments(array('source_type' => 'tid'));
$this->addFieldMapping('body', 'body');
$this->addFieldMapping('teaser', 'excerpt');
@@ -267,7 +267,7 @@ class WineProducerXMLMigration extends XMLMigration {
public function __construct() {
parent::__construct();
$this->description = t('XML feed of wine producers of the world');
- $this->dependencies = array('WineRegionMigration', 'WineUserMigration');
+ $this->dependencies = array('WineRegion', 'WineUser');
// There isn't a consistent way to automatically identify appropriate "fields"
// from an XML feed, so we pass an explicit list of source fields
@@ -316,7 +316,7 @@ class WineProducerXMLMigration extends XMLMigration {
->xpath('/producer/name');
$this->addFieldMapping('uid', 'authorid')
->xpath('/producer/authorid')
- ->sourceMigration('WineUserMigration')
+ ->sourceMigration('WineUser')
->defaultValue(1);
$this->addFieldMapping('Migrate Example Wine Regions', 'region')
->xpath('/producer/region');
@@ -330,8 +330,8 @@ class WineWineMigration extends AdvancedExampleMigration {
public function __construct() {
parent::__construct();
$this->description = t('Wines of the world');
- $this->dependencies = array('WineVarietyMigration', 'WineRegionMigration',
- 'WineBestWithMigration', 'WineUserMigration', 'WineProducerMigration');
+ $this->dependencies = array('WineVariety', 'WineRegion',
+ 'WineBestWith', 'WineUser', 'WineProducer');
$this->map = new MigrateSQLMap($this->machineName,
array(
@@ -391,21 +391,21 @@ class WineWineMigration extends AdvancedExampleMigration {
$this->addFieldMapping('title', 'name')
->description(t('Mapping wine name in source to node title'));
$this->addFieldMapping('uid', 'accountid')
- ->sourceMigration('WineUserMigration')
+ ->sourceMigration('WineUser')
->defaultValue(1);
// TIP: By default, term relationship are assumed to be passed by name.
// In this case, the source values are IDs, so we specify the relevant
// migration (so the tid can be looked up in the map), and tell the term
// field handler that it is receiving tids instead of names
$this->addFieldMapping('Migrate Example Wine Varieties', 'variety')
- ->sourceMigration('WineVarietyMigration')
+ ->sourceMigration('WineVariety')
->arguments(array('source_type' => 'tid'));
$this->addFieldMapping('Migrate Example Wine Regions', 'region')
- ->sourceMigration('WineRegionMigration')
+ ->sourceMigration('WineRegion')
->arguments(array('source_type' => 'tid'));
$this->addFieldMapping('Migrate Example Wine Best With', 'best_with')
->separator(',')
- ->sourceMigration('WineBestWithMigration')
+ ->sourceMigration('WineBestWith')
->arguments(array('source_type' => 'tid'));
$this->addFieldMapping('field_migrate_example_wine_ratin', 'rating');
$this->addFieldMapping('field_migrate_example_wine_rvw', 'last_reviewed');
@@ -461,7 +461,7 @@ class WineCommentMigration extends AdvancedExampleMigration {
public function __construct() {
parent::__construct();
$this->description = 'Comments about wines';
- $this->dependencies = array('WineUserMigration', 'WineWineMigration');
+ $this->dependencies = array('WineUser', 'WineWine');
$this->map = new MigrateSQLMap($this->machineName,
array('commentid' => array(
'type' => 'int',
@@ -486,12 +486,12 @@ class WineCommentMigration extends AdvancedExampleMigration {
$this->addFieldMapping('status')
->defaultValue(COMMENT_PUBLISHED);
$this->addFieldMapping('nid', 'wineid')
- ->sourceMigration('WineWineMigration');
+ ->sourceMigration('WineWine');
$this->addFieldMapping('uid', 'accountid')
- ->sourceMigration('WineUserMigration')
+ ->sourceMigration('WineUser')
->defaultValue(0);
$this->addFieldMapping('pid', 'comment_parent')
- ->sourceMigration('WineCommentMigration')
+ ->sourceMigration('WineComment')
->description('Parent comment');
$this->addFieldMapping('comment', 'body');
$this->addFieldMapping('hostname', 'commenthost');
@@ -513,7 +513,7 @@ class WineFinishMigration extends MigrationBase {
parent::__construct();
$this->description = t('If auto_nodetitle is present and was previously enabled,
re-enable it');
- $this->dependencies = array('WineCommentMigration');
+ $this->dependencies = array('WineComment');
}
public function isComplete() {
if (module_exists('auto_nodetitle')) {
@@ -544,8 +544,8 @@ class WineUpdatesMigration extends AdvancedExampleMigration {
public function __construct() {
parent::__construct();
$this->description = t('Update wine ratings');
- $this->dependencies = array('WineWineMigration');
- $this->softDependencies = array('WineFinishMigration');
+ $this->dependencies = array('WineWine');
+ $this->softDependencies = array('WineFinish');
$this->map = new MigrateSQLMap($this->machineName,
array(
@@ -576,7 +576,7 @@ class WineUpdatesMigration extends AdvancedExampleMigration {
// has a source id, not a nid, we need to apply the original wine migration
// mapping to populate the nid.
$this->addFieldMapping('nid', 'wineid')
- ->sourceMigration('WineWineMigration');
+ ->sourceMigration('WineWine');
$this->addFieldMapping('field_migrate_example_wine_ratin', 'rating');
// No unmapped source fields
@@ -608,8 +608,8 @@ class WineCommentUpdatesMigration extends AdvancedExampleMigration {
public function __construct() {
parent::__construct();
$this->description = 'Update wine comments';
- $this->dependencies = array('WineCommentMigration');
- $this->softDependencies = array('WineUpdatesMigration');
+ $this->dependencies = array('WineComment');
+ $this->softDependencies = array('WineUpdates');
$this->map = new MigrateSQLMap($this->machineName,
array('commentid' => array(
'type' => 'int',
@@ -627,7 +627,7 @@ class WineCommentUpdatesMigration extends AdvancedExampleMigration {
// Mapped fields
$this->addFieldMapping('cid', 'commentid')
- ->sourceMigration('WineCommentMigration');
+ ->sourceMigration('WineComment');
$this->addFieldMapping('subject', 'subject');
// No unmapped source fields
@@ -655,8 +655,8 @@ class WineVarietyUpdatesMigration extends AdvancedExampleMigration {
public function __construct() {
parent::__construct();
$this->description = t('Migrate varieties from the source database to taxonomy terms');
- $this->dependencies = array('WineVarietyMigration');
- $this->softDependencies = array('WineUpdatesMigration');
+ $this->dependencies = array('WineVariety');
+ $this->softDependencies = array('WineUpdates');
$this->map = new MigrateSQLMap($this->machineName,
array(
'categoryid' => array('type' => 'int',
@@ -675,7 +675,7 @@ class WineVarietyUpdatesMigration extends AdvancedExampleMigration {
// Mapped fields
$this->addFieldMapping('tid', 'categoryid')
- ->sourceMigration('WineVarietyMigration');
+ ->sourceMigration('WineVariety');
$this->addFieldMapping('description', 'details');
// Unmapped source fields
@@ -695,8 +695,8 @@ class WineUserUpdatesMigration extends AdvancedExampleMigration {
public function __construct() {
parent::__construct();
$this->description = t('Account updates');
- $this->dependencies = array('WineUserMigration');
- $this->softDependencies = array('WineUpdatesMigration');
+ $this->dependencies = array('WineUser');
+ $this->softDependencies = array('WineUpdates');
$this->map = new MigrateSQLMap($this->machineName,
array('accountid' => array(
'type' => 'int',
@@ -715,7 +715,7 @@ class WineUserUpdatesMigration extends AdvancedExampleMigration {
// Mapped fields
$this->addFieldMapping('uid', 'accountid')
- ->sourceMigration('WineUserMigration');
+ ->sourceMigration('WineUser');
// Unmapped source fields
diff --git a/migrate_ui/migrate_ui.module b/migrate_ui/migrate_ui.module
index d2e87d5..f93d022 100644
--- a/migrate_ui/migrate_ui.module
+++ b/migrate_ui/migrate_ui.module
@@ -58,8 +58,7 @@ function migrate_menu() {
// A menu load callback.
function migration_load($machine_name) {
if ($machine_name) {
- $class_name = $machine_name . 'Migration';
- return Migration::getInstance($class_name);
+ return Migration::getInstance($machine_name);
}
}
diff --git a/tests/plugins/destinations/comment.test b/tests/plugins/destinations/comment.test
index b76bd58..614ad70 100644
--- a/tests/plugins/destinations/comment.test
+++ b/tests/plugins/destinations/comment.test
@@ -26,31 +26,31 @@ class MigrateCommentUnitTest extends DrupalWebTestCase {
}
function testCommentImport() {
- $migration = Migration::getInstance('WineVarietyMigration');
+ $migration = Migration::getInstance('WineVariety');
$result = $migration->processImport();
$this->assertEqual($result, Migration::RESULT_COMPLETED,
t('Variety term import returned RESULT_COMPLETED'));
- $migration = Migration::getInstance('WineRegionMigration');
+ $migration = Migration::getInstance('WineRegion');
$result = $migration->processImport();
$this->assertEqual($result, Migration::RESULT_COMPLETED,
t('Region term import returned RESULT_COMPLETED'));
- $migration = Migration::getInstance('WineBestWithMigration');
+ $migration = Migration::getInstance('WineBestWith');
$result = $migration->processImport();
$this->assertEqual($result, Migration::RESULT_COMPLETED,
t('"Best With" term import returned RESULT_COMPLETED'));
- $migration = Migration::getInstance('WineUserMigration');
+ $migration = Migration::getInstance('WineUser');
$result = $migration->processImport();
$this->assertEqual($result, Migration::RESULT_COMPLETED,
t('User import returned RESULT_COMPLETED'));
- $migration = Migration::getInstance('WineProducerMigration');
+ $migration = Migration::getInstance('WineProducer');
$result = $migration->processImport();
$this->assertEqual($result, Migration::RESULT_COMPLETED,
t('Producer node import returned RESULT_COMPLETED'));
- $migration = Migration::getInstance('WineWineMigration');
+ $migration = Migration::getInstance('WineWine');
$result = $migration->processImport();
$this->assertEqual($result, Migration::RESULT_COMPLETED,
t('Wine node import returned RESULT_COMPLETED'));
- $migration = Migration::getInstance('WineCommentMigration');
+ $migration = Migration::getInstance('WineComment');
$result = $migration->processImport();
$this->assertEqual($result, Migration::RESULT_COMPLETED,
t('Comment import returned RESULT_COMPLETED'));
@@ -85,7 +85,7 @@ class MigrateCommentUnitTest extends DrupalWebTestCase {
$this->assertEqual($comment->mail, $row->mail, t('Mail matches'));
$this->assertEqual($comment->name, $row->name, t('Name matches'));
$this->assertEqual($comment->status, COMMENT_PUBLISHED, t('Status matches'));
- $wine_migration = MigrationBase::getInstance('WineWineMigration');
+ $wine_migration = MigrationBase::getInstance('WineWine');
$destid = $wine_migration->getMap()->lookupDestinationID(array($row->wineid), $migration);
$this->assertEqual($comment->nid, reset($destid), t('Nid matches'));
$this->assertEqual($comment->comment, $row->body, t('Body matches'));
@@ -95,7 +95,7 @@ class MigrateCommentUnitTest extends DrupalWebTestCase {
$comment = $comments['im child'];
$row = $rows['im child'];
- $user_migration = MigrationBase::getInstance('WineUserMigration');
+ $user_migration = MigrationBase::getInstance('WineUser');
$destid = $user_migration->getMap()->lookupDestinationID(array($row->accountid), $migration);
$this->assertEqual($comment->uid, reset($destid), t('Uid matches'));
$this->assertEqual($comment->pid, $comments['im parent']->cid, t('Parent matches'));
diff --git a/tests/plugins/destinations/node.test b/tests/plugins/destinations/node.test
index fcc34a1..5c233db 100644
--- a/tests/plugins/destinations/node.test
+++ b/tests/plugins/destinations/node.test
@@ -25,27 +25,27 @@ class MigrateNodeUnitTest extends DrupalWebTestCase {
}
function testNodeImport() {
- $migration = Migration::getInstance('WineVarietyMigration');
+ $migration = Migration::getInstance('WineVariety');
$result = $migration->processImport();
$this->assertEqual($result, Migration::RESULT_COMPLETED,
t('Variety term import returned RESULT_COMPLETED'));
- $migration = Migration::getInstance('WineRegionMigration');
+ $migration = Migration::getInstance('WineRegion');
$result = $migration->processImport();
$this->assertEqual($result, Migration::RESULT_COMPLETED,
t('Region term import returned RESULT_COMPLETED'));
- $migration = Migration::getInstance('WineBestWithMigration');
+ $migration = Migration::getInstance('WineBestWith');
$result = $migration->processImport();
$this->assertEqual($result, Migration::RESULT_COMPLETED,
t('"Best With" term import returned RESULT_COMPLETED'));
- $migration = Migration::getInstance('WineUserMigration');
+ $migration = Migration::getInstance('WineUser');
$result = $migration->processImport();
$this->assertEqual($result, Migration::RESULT_COMPLETED,
t('User import returned RESULT_COMPLETED'));
- $migration = Migration::getInstance('WineProducerMigration');
+ $migration = Migration::getInstance('WineProducer');
$result = $migration->processImport();
$this->assertEqual($result, Migration::RESULT_COMPLETED,
t('Producer node import returned RESULT_COMPLETED'));
- $migration = Migration::getInstance('WineWineMigration');
+ $migration = Migration::getInstance('WineWine');
$result = $migration->processImport();
$this->assertEqual($result, Migration::RESULT_COMPLETED,
t('Wine node import returned RESULT_COMPLETED'));
@@ -109,7 +109,7 @@ class MigrateNodeUnitTest extends DrupalWebTestCase {
$producer_row = $producer_rows['Montes'];
$wine_node = $wine_nodes['Montes Classic Cabernet Sauvignon'];
$wine_row = $wine_rows['Montes Classic Cabernet Sauvignon'];
- $user_migration = MigrationBase::getInstance('WineUserMigration');
+ $user_migration = MigrationBase::getInstance('WineUser');
$mapped_uid = $user_migration->getMap()->lookupDestinationID(
array($producer_row->accountid), $migration);
@@ -130,7 +130,7 @@ class MigrateNodeUnitTest extends DrupalWebTestCase {
t('teaser properly migrated'));
// Taxonomy terms - single and multiple
- $variety_migration = MigrationBase::getInstance('WineVarietyMigration');
+ $variety_migration = MigrationBase::getInstance('WineVariety');
$mapped_tid = $variety_migration->getMap()->lookupDestinationID(
array($wine_row->variety), $migration);
if (is_array($mapped_tid)) {
@@ -141,7 +141,7 @@ class MigrateNodeUnitTest extends DrupalWebTestCase {
$this->error(t('Variety !var not migrated', array('!var' => $wine_row->variety)));
}
- $best_with_migration = MigrationBase::getInstance('WineBestWithMigration');
+ $best_with_migration = MigrationBase::getInstance('WineBestWith');
$source_ids = explode(',', $wine_row->best_with);
$mapped_tids = array();
foreach ($source_ids as $source_id) {
@@ -195,7 +195,7 @@ class MigrateNodeUnitTest extends DrupalWebTestCase {
->condition('wineid', 2)
->execute();
- $migration = Migration::getInstance('WineWineMigration');
+ $migration = Migration::getInstance('WineWine');
$result = $migration->processImport();
$this->assertEqual($result, Migration::RESULT_COMPLETED,
diff --git a/tests/plugins/destinations/term.test b/tests/plugins/destinations/term.test
index 74a3381..4293aa7 100644
--- a/tests/plugins/destinations/term.test
+++ b/tests/plugins/destinations/term.test
@@ -21,7 +21,7 @@ class MigrateTaxonomyUnitTest extends DrupalWebTestCase {
}
function testTermImport() {
- $migration = Migration::getInstance('WineVarietyMigration');
+ $migration = Migration::getInstance('WineVariety');
$result = $migration->processImport();
$this->assertEqual($result, Migration::RESULT_COMPLETED,
t('Variety term import returned RESULT_COMPLETED'));
@@ -71,7 +71,7 @@ class MigrateTaxonomyUnitTest extends DrupalWebTestCase {
foreach ($tempterms as $tid => $term) {
$original_terms[$tid] = clone $term;
}
- $update_migration = Migration::getInstance('WineVarietyUpdatesMigration');
+ $update_migration = Migration::getInstance('WineVarietyUpdates');
$result = $update_migration->processImport();
$this->assertEqual($result, Migration::RESULT_COMPLETED,
diff --git a/tests/plugins/destinations/user.test b/tests/plugins/destinations/user.test
index b78ab61..239a418 100644
--- a/tests/plugins/destinations/user.test
+++ b/tests/plugins/destinations/user.test
@@ -24,7 +24,7 @@ class MigrateUserUnitTest extends DrupalWebTestCase {
}
function testUserImport() {
- $migration = Migration::getInstance('WineUserMigration');
+ $migration = Migration::getInstance('WineUser');
$result = $migration->processImport();
$this->assertEqual($result, Migration::RESULT_COMPLETED,
t('User import returned RESULT_COMPLETED'));
diff --git a/tests/plugins/sources/xml.test b/tests/plugins/sources/xml.test
index 6d72138..4574596 100644
--- a/tests/plugins/sources/xml.test
+++ b/tests/plugins/sources/xml.test
@@ -26,15 +26,15 @@ class MigrateXMLUnitTest extends DrupalWebTestCase {
}
function testXMLImport() {
- $migration = Migration::getInstance('WineRegionMigration');
+ $migration = Migration::getInstance('WineRegion');
$result = $migration->processImport();
$this->assertEqual($result, Migration::RESULT_COMPLETED,
t('Region term import returned RESULT_COMPLETED'));
- $migration = Migration::getInstance('WineUserMigration');
+ $migration = Migration::getInstance('WineUser');
$result = $migration->processImport();
$this->assertEqual($result, Migration::RESULT_COMPLETED,
t('User import returned RESULT_COMPLETED'));
- $migration = Migration::getInstance('WineProducerXMLMigration');
+ $migration = Migration::getInstance('WineProducerXML');
$result = $migration->processImport();
$this->assertEqual($result, Migration::RESULT_COMPLETED,
t('Producer node import returned RESULT_COMPLETED'));
@@ -55,7 +55,7 @@ class MigrateXMLUnitTest extends DrupalWebTestCase {
// Test each base node field
$producer_node = $producer_nodes['Lolonis Winery'];
- $user_migration = MigrationBase::getInstance('WineUserMigration');
+ $user_migration = MigrationBase::getInstance('WineUser');
$mapped_uid = $user_migration->getMap()->lookupDestinationID(
array(3), $migration);