migrate.api.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <?php
  2. /**
  3. * @file
  4. * Documentation for hooks defined by Migrate.
  5. */
  6. /**
  7. * Registers your module as an implementor of Migrate-based classes and
  8. * provides
  9. * default configuration for migration processes.
  10. *
  11. * @return
  12. * An associative array with the following keys (of which only 'api' is
  13. * required):
  14. * - api: Always 2 for any module implementing the Migrate 2 API.
  15. * - groups: An associative array, keyed by group machine name, defining one
  16. * or more migration groups. Each value is an associative array - the
  17. * 'title' key defines a user-visible name for the group; any other values
  18. * are passed as arguments to all migrations in the group.
  19. * - migrations: An associative array, keyed by migration machine name,
  20. * defining one or more migrations. Each value is an associative array -
  21. * any
  22. * keys other than the following are passed as arguments to the migration
  23. * constructor:
  24. * - class_name (required): The name of the class implementing the
  25. * migration.
  26. * - group_name: The machine name of the group containing the migration.
  27. * - disable_hooks: An associative array, keyed by hook name, listing hook
  28. * implementations to be disabled during migration. Each value is an
  29. * array of module names whose implementations of the hook in the key is
  30. * to be disabled.
  31. * - destination handlers: An array of classes implementing destination
  32. * handlers.
  33. * - field handlers: An array of classes implementing field handlers.
  34. * - wizard classes: An array of classes that provide Migrate UI wizards.
  35. * - wizard extenders: An array of classes that extend Migrate UI wizards.
  36. * Keys are the wizard classes, values are arrays of extender classes.
  37. *
  38. * See system_hook_info() for all hook groups defined by Drupal core.
  39. *
  40. * @see hook_migrate_api_alter().
  41. */
  42. function hook_migrate_api() {
  43. $api = array(
  44. 'api' => 2,
  45. 'groups' => array(
  46. 'legacy' => array(
  47. 'title' => t('Import from legacy system'),
  48. // Default format for all content migrations
  49. 'default_format' => 'filtered_html',
  50. ),
  51. ),
  52. 'migrations' => array(
  53. 'ExampleUser' => array(
  54. 'class_name' => 'ExampleUserMigration',
  55. 'group_name' => 'legacy',
  56. 'default_role' => 'member', // Added to constructor $arguments
  57. ),
  58. 'ExampleNode' => array(
  59. 'class_name' => 'ExampleNodeMigration',
  60. 'group_name' => 'legacy',
  61. 'default_uid' => 1, // Added to constructor $arguments
  62. 'disable_hooks' => array(
  63. // Improve migration performance, and prevent accidental emails.
  64. 'node_insert' => array(
  65. 'expensive_module',
  66. 'email_notification_module',
  67. ),
  68. 'node_update' => array(
  69. 'expensive_module',
  70. 'email_notification_module',
  71. ),
  72. ),
  73. ),
  74. ),
  75. );
  76. return $api;
  77. }
  78. /**
  79. * Alter information from all implementations of hook_migrate_api().
  80. *
  81. * @param array $info
  82. * An array of results from hook_migrate_api(), keyed by module name.
  83. *
  84. * @see hook_migrate_api().
  85. */
  86. function hook_migrate_api_alter(array &$info) {
  87. // Override the class for another module's migration - say, to add some
  88. // additional preprocessing in prepareRow().
  89. if (isset($info['MODULE_NAME']['migrations']['ExampleNode'])) {
  90. $info['MODULE_NAME']['migrations']['ExampleNode']['class_name'] = 'MyBetterExampleNodeMigration';
  91. }
  92. }
  93. /**
  94. * Provides text to be displayed at the top of the dashboard page (migrate_ui).
  95. *
  96. * @return
  97. * Translated text for display on the dashboard page.
  98. */
  99. function hook_migrate_overview() {
  100. return t('<p>Listed below are all the migration processes defined for migration
  101. of our old site to Drupal. Open issues applying to specific migrations
  102. can be viewed by clicking the migration name. Also, details on how each
  103. migration will behave when incrementally migrated are provided.</p>
  104. <p><a href="http://issuetracker.example.com/?project=migration&status=open">Open migration tickets</a></p>');
  105. }