You are here

function migrate_static_registration in Migrate 7.2

Register any migrations defined in hook_migrate_api().

Parameters

array $machine_names: If populated, only (re)register the specified migrations.

13 calls to migrate_static_registration()
drush_migrate_register in ./migrate.drush.inc
Register any migrations defined in hook_migrate_api().
MigrateCommentUnitTest::setUp in tests/plugins/destinations/comment.test
Sets up a Drupal site for running functional and integration tests.
MigrateImportOptionsTest::setUp in tests/import/options.test
Sets up a Drupal site for running functional and integration tests.
MigrateNodeUnitTest::setUp in tests/plugins/destinations/node.test
Sets up a Drupal site for running functional and integration tests.
MigrateOracleUnitTest::setUp in tests/plugins/sources/oracle.test
Sets up a Drupal site for running functional and integration tests.

... See full list

File

./migrate.module, line 367
API and drush commands to support migration of data from external sources into a Drupal installation.

Code

function migrate_static_registration($machine_names = array()) {
  $module_info = migrate_get_module_apis(TRUE);
  foreach ($module_info as $module => $info) {

    // Register any groups defined via the hook.
    if (isset($info['groups']) && is_array($info['groups'])) {
      foreach ($info['groups'] as $name => $arguments) {
        $title = $arguments['title'];
        unset($arguments['title']);
        MigrateGroup::register($name, $title, $arguments);
      }
    }

    // Register any migrations defined via the hook.
    if (isset($info['migrations']) && is_array($info['migrations'])) {
      foreach ($info['migrations'] as $machine_name => $arguments) {

        // If we have an explicit list to register, skip any not in the list.
        if (!empty($machine_names) && !in_array($machine_name, $machine_names)) {
          continue;
        }
        $class_name = $arguments['class_name'];
        unset($arguments['class_name']);

        // Call the right registerMigration implementation. Note that this means
        // that classes that override registerMigration() must always call it
        // directly, they cannot register those classes by defining them in
        // hook_migrate_api() and expect their extension to be called.
        if (is_subclass_of($class_name, 'Migration')) {
          Migration::registerMigration($class_name, $machine_name, $arguments);
        }
        else {
          MigrationBase::registerMigration($class_name, $machine_name, $arguments);
        }
      }
    }
  }
}