migrate.d8.drush.inc

Migrate content into Drupal 8+.

Functions

Namesort descending Description
drush_migrate_manifest Import from a manifest file.
drush_migrate_manifest_get_class Get a version specific MigrateManifest class.
migrate_drush_command Implements hook_drush_command().

File

commands/core/migrate.d8.drush.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. * Migrate content into Drupal 8+.
  5. */
  6. /**
  7. * Implements hook_drush_command().
  8. */
  9. function migrate_drush_command() {
  10. $items['migrate-manifest'] = array(
  11. 'description' => 'Execute the migrations as specified in a manifest file.',
  12. 'arguments' => array(
  13. 'manifest' => 'The path to the manifest file',
  14. ),
  15. 'required-arguments' => 1,
  16. 'options' => array(
  17. 'legacy-db-url' => array(
  18. 'description' => 'A Drupal 6 style database URL.',
  19. 'example-value' => 'mysql://root:pass@127.0.0.1/db',
  20. 'required' => TRUE,
  21. ),
  22. ),
  23. 'drupal dependencies' => array('migrate_drupal'),
  24. );
  25. return $items;
  26. }
  27. /**
  28. * Import from a manifest file.
  29. *
  30. * This command allows you to specify a list of migrations and their config in
  31. * a YAML file. An example of a simple migration may look like this:
  32. *
  33. * @code
  34. * - d6_action_settings
  35. * - d6_aggregator_feed
  36. * @endcode
  37. *
  38. * You can also provide configuration to a migration for both source and the
  39. * destination. An example as such:
  40. *
  41. * @code
  42. * - d6_file:
  43. * source:
  44. * conf_path: sites/assets
  45. * destination:
  46. * source_base_path: destination/base/path
  47. * destination_path_property: uri
  48. * - d6_action_settings
  49. * @endcode
  50. *
  51. * @param string $manifest
  52. * The path to the manifest file.
  53. */
  54. function drush_migrate_manifest($manifest) {
  55. try {
  56. return drush_migrate_manifest_get_class($manifest)->import();
  57. }
  58. catch (\Exception $e) {
  59. drush_set_error('MIGRATE_ERROR', $e->getMessage());
  60. }
  61. drush_invoke_process('@self', 'cache-rebuild', array(), array(), FALSE);
  62. }
  63. /**
  64. * Get a version specific MigrateManifest class.
  65. *
  66. * @param string $manifest
  67. * The path to the manifest file.
  68. *
  69. * @return \Drush\Migrate\MigrateInterface
  70. * The migrate manifest class.
  71. *
  72. * @see drush_get_class().
  73. */
  74. function drush_migrate_manifest_get_class($manifest) {
  75. return drush_get_class('Drush\Migrate\MigrateManifest', array($manifest));
  76. }