You are here

public static function MigrationBase::registerMigration in Migrate 6.2

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

Register a new migration process in the migrate_status table. This will generally be used in two contexts - by the class detection code for static (one instance per class) migrations, and by the module implementing dynamic (parameterized class) migrations.

Parameters

string $class_name:

string $machine_name:

array $arguments:

2 calls to MigrationBase::registerMigration()
migrate_autoregister in ./migrate.module
On request, scan the Drupal code registry for any new migration classes for us to register in migrate_status.
migrate_get_module_apis in ./migrate.module
Get a list of modules that support the current migrate API.

File

includes/base.inc, line 362
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 registerMigration($class_name, $machine_name = NULL, array $arguments = array()) {
  if (!$machine_name) {
    $machine_name = self::machineFromClass($class_name);
  }
  if (!preg_match('|^[a-z0-9_]+$|i', $machine_name)) {
    throw new Exception(t('!name is not a valid Migration machine name. Use only alphanumeric or underscore characters.', array(
      '!name' => $machine_name,
    )));
  }

  // Making sure the machine name is in the arguments array helps with
  // chicken-and-egg problems in determining the machine name.
  if (!isset($arguments['machine_name'])) {
    $arguments['machine_name'] = $machine_name;
  }

  // Register the migration if it's not already there; if it is,
  // update the class and arguments in case they've changed.
  db_merge('migrate_status')
    ->key(array(
    'machine_name' => $machine_name,
  ))
    ->fields(array(
    'class_name' => $class_name,
    'arguments' => serialize($arguments),
  ))
    ->execute();
}