1

I have a use case where I want to use the callbacks functionality for the body field in a D6->D7 migration using migrate and migrate_d2d modules. However, according to the above-referenced docs page, this is done when you are adding a new field mapping:

$this->addFieldMapping('destination_field', 'source_field')->callbacks('my_callback');

not adding to an existing mapping. How can I add a callback to an existing mapping? Do I have to remove and then re-add the mapping, or is there another way?

1

With some debugging and looking at code, it turned out to be pretty easy. All of the mappings are MigrateFieldMapping objects in $this->codedFieldMappings, so it's just a matter of getting a reference to that object and calling the callbacks() method. For example, to add a callback to the body field, you would use:

$this->codedFieldMappings['body']->callbacks('my_callback');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.