You are here

public static function MigrationBase::registerMigration in Migrate 7.2

Same name and namespace in other branches
  1. 6.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:

3 calls to MigrationBase::registerMigration()
MigrateUIWizard::formSaveSettings in migrate_ui/migrate_ui.wizard.inc
Take the information we've accumulated throughout the wizard, and create the Migrations to perform the import.
migrate_static_registration in ./migrate.module
Register any migrations defined in hook_migrate_api().
Migration::registerMigration in includes/migration.inc
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)…
1 method overrides MigrationBase::registerMigration()
Migration::registerMigration in includes/migration.inc
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)…

File

includes/base.inc, line 521
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()) {

  // Support for legacy migration code - in later releases, the machine_name
  // should always be explicit.
  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,
    )));
  }

  // We no longer have any need to store the machine_name in the arguments.
  if (isset($arguments['machine_name'])) {
    unset($arguments['machine_name']);
  }
  if (isset($arguments['group_name'])) {
    $group_name = $arguments['group_name'];
    unset($arguments['group_name']);
  }
  else {
    $group_name = 'default';
  }
  $arguments = self::encryptArguments($arguments);

  // 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,
    'group_name' => $group_name,
    'arguments' => serialize($arguments),
  ))
    ->execute();
}