You are here

public static function MigrationBase::getInstance in Migrate 6.2

Same name and namespace in other branches
  1. 7.2 includes/base.inc \MigrationBase::getInstance()

Return the single instance of the given migration.

Parameters

string $machine_name:

9 calls to MigrationBase::getInstance()
drush_migrate_messages in ./migrate.drush.inc
Display messages for a migration.
drush_migrate_status in ./migrate.drush.inc
A simplified version of the dashboard page.
MigrateCommentUnitTest::testCommentImport in tests/plugins/destinations/comment.test
MigrateNodeUnitTest::testNodeImport in tests/plugins/destinations/node.test
MigrateXMLUnitTest::testXMLImport in tests/plugins/sources/xml.test

... See full list

File

includes/base.inc, line 425
Defines the base class for migration processes.

Class

MigrationBase
The base class for all objects representing distinct steps in a migration process. Most commonly these will be Migration objects which actually import data from a source into a Drupal destination, but by deriving classes directly from MigrationBase…

Code

public static function getInstance($machine_name, $class_name = NULL, array $arguments = array()) {

  // Otherwise might miss cache hit on case difference
  $machine_name_key = strtolower($machine_name);
  if (!isset(self::$migrations[$machine_name_key])) {

    // Skip the query if our caller already made it
    if (!$class_name) {

      // See if we know about this migration
      $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 {

        // Can't find a migration with this name
        throw new MigrateException(t('No migration found with machine name !machine', array(
          '!machine' => $machine_name,
        )));
      }
    }
    self::$migrations[$machine_name_key] = new $class_name($arguments);
  }
  return self::$migrations[$machine_name_key];
}