You are here

function hook_migrate_api in Migrate 7.2

Same name and namespace in other branches
  1. 6.2 migrate.api.php \hook_migrate_api()

Registers your module as an implementor of Migrate-based classes and provides default configuration for migration processes.

Return value

An associative array with the following keys (of which only 'api' is required):

  • api: Always 2 for any module implementing the Migrate 2 API.
  • groups: An associative array, keyed by group machine name, defining one or more migration groups. Each value is an associative array - the

'title' key defines a user-visible name for the group; any other values are passed as arguments to all migrations in the group.

  • migrations: An associative array, keyed by migration machine name, defining one or more migrations. Each value is an associative array -

any keys other than the following are passed as arguments to the migration constructor:

  • class_name (required): The name of the class implementing the

migration.

  • group_name: The machine name of the group containing the migration.
  • disable_hooks: An associative array, keyed by hook name, listing hook implementations to be disabled during migration. Each value is an array of module names whose implementations of the hook in the key is to be disabled.
  • destination handlers: An array of classes implementing destination handlers.
  • field handlers: An array of classes implementing field handlers.
  • wizard classes: An array of classes that provide Migrate UI wizards.
  • wizard extenders: An array of classes that extend Migrate UI wizards. Keys are the wizard classes, values are arrays of extender classes.

See system_hook_info() for all hook groups defined by Drupal core.

See also

hook_migrate_api_alter().

4 functions implement hook_migrate_api()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

migrate_example_baseball_migrate_api in migrate_example_baseball/migrate_example_baseball.migrate.inc
migrate_example_migrate_api in migrate_example/migrate_example.migrate.inc
migrate_example_oracle_migrate_api in migrate_example/migrate_example_oracle/migrate_example_oracle.migrate.inc
migrate_migrate_api in ./migrate.migrate.inc
2 invocations of hook_migrate_api()
migrate_get_module_apis in ./migrate.module
Get a list of modules that support the current migrate API.
migrate_modules_enabled in ./migrate.module
Implements hook_modules_enabled.

File

./migrate.api.php, line 44
Documentation for hooks defined by Migrate.

Code

function hook_migrate_api() {
  $api = array(
    'api' => 2,
    'groups' => array(
      'legacy' => array(
        'title' => t('Import from legacy system'),
        // Default format for all content migrations
        'default_format' => 'filtered_html',
      ),
    ),
    'migrations' => array(
      'ExampleUser' => array(
        'class_name' => 'ExampleUserMigration',
        'group_name' => 'legacy',
        'default_role' => 'member',
      ),
      'ExampleNode' => array(
        'class_name' => 'ExampleNodeMigration',
        'group_name' => 'legacy',
        'default_uid' => 1,
        // Added to constructor $arguments
        'disable_hooks' => array(
          // Improve migration performance, and prevent accidental emails.
          'node_insert' => array(
            'expensive_module',
            'email_notification_module',
          ),
          'node_update' => array(
            'expensive_module',
            'email_notification_module',
          ),
        ),
      ),
    ),
  );
  return $api;
}