prepareFieldFile has a bunch of validation and if validation fails, it currently throws an exception. that exception currently stops the import. instead, i would prefer for an error to be logged for the current row and the migration proceeds. lets show how this should be done.

note that we have discussed breaking out prepare functions as own plugins. this would help handle custom fields cleanly. I actually think that each field type should probably be a plugin. I see some merit in specific fieldMappingCallbacks like addFieldMappingCallbackFile which has specific methods/properties which deal with files. I know that this is a regression in some ways but it is an improvement in clarity when your IDE shows you the supported prorties/methods.

Sorry to merge two related issues into one.

Comments

mikeryan’s picture

Working now on exception handling.

I did some thinking about breaking out the prepare functions after it first came up, and there was some reason I thought that wouldn't work. Now if I can only remember what that was...

mikeryan’s picture

Status: Active » Fixed

I've committed a refactoring of field handling. One can add a handler for field type foo_bar by defining class ExampleFooBarFieldHandler, extending MigrateFieldHandler, and implementing prepare(array $field_info, array $instance, array $values). One can also define a convenience function arguments(), for building an argument array (such as to pass summary/format/language for a text field). Check out plugins/destinations/fields.inc.

moshe weitzman’s picture

FYI, I just implemented a custom FieldHandler and it worked as advertised. Nice!

Status: Fixed » Closed (fixed)

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