I have a sample use case which I think others might have. I have written a platform distribution that includes a migration from its Drupal 6 version. For individual sites that use my platform, but have added extra fields to their content types, etc, they need to be able to 'alter' the platform migrations by extending the existing classes and add the support for the additional field mappings as needed. Currently I cannot find any way to do this, but I have investigated that adding an alter hook to hook_migrate_api() seems to be the best option.

Comments

dave reid’s picture

Status: Active » Needs review
StatusFileSize
new1.43 KB

Patch attached which adds the new alter hook. I think this is a great idea because it means that calculating dependencies works just great but I'm able to switch out the class easily:

/**
 * Implements hook_migrate_api_alter().
 */
function mymodule_migrate_api_alter(array &$info) {
  if (isset($info['other_module']['migrations']['OtherModule'])) {
    $info['other_module']['migrations']['OtherModule']['class_name'] = 'MyBetterOtherModuleMigration';
  }
}

class MyBetterOtherModuleMigration extends OtherModuleMigration {
  // Override __construct(), prepareRow(), prepare(), etc as needed.
}
dave reid’s picture

Patch attached against 7.x-2.5 not for testing, but for make files only.

dave reid’s picture

Revised and corrected version of #2 against 7.x-2.5 release.

dave reid’s picture

I really fail at this 7.x-2.5 patch. Another try.

mikeryan’s picture

Status: Needs review » Fixed
Issue tags: +Migrate 2.6

Alter all the hooks!

Committed, thanks.

Automatically closed -- issue fixed for 2 weeks with no activity.