I'm trying to combine normal File fields and Flickr fields into one Media field, but defining a file_class per row doesn't seem supported.
In the /plugins/destinations/fields.inc file, in the MigrateFileFieldBaseHandler class a general fileclass argument is used, instead of the file_class from the instance_arguments. This caused this part of the code to break when fileclass is an array.
One temp fix seems to be to add
$file_class = $instance_arguments['file_class'];
above the following
$source = new $file_class($instance_arguments);
But this does put the whole $migration->getOption('file_function') parts out of play.
Comments
Comment #1
mikeryanThe file class really does need to be static, not a per-row argument, because each file class has its own set of supported subfields - how would you map the subfields in your constructor?
My preferred approach here would be to have separate MigrateDestinationFile migrations for regular files and Flickr images, then you can easily have a MigrateFileFid class to pull them together (with sourceMigration(array('Files', 'FlickrImages'))).
Comment #2
peteruithoven commentedI mapped it like this.
The media_filepath, media_file_class, media_display and images_description are arrays added as source fields that I fill in prepareRow. In media_filepath I add the filepath to the local files and the url's (inc flickr.com) for flickr images.
This seems to work partly, I get the following messages about timeout's and it doesn't migrate all the items.
simplexml_load_file(http://api.flickr.com/...) [function.simplexml-load-file]: failed to open stream: Operation timed out File .../modules/media/includes/media.xml.inc, line 38But... that gives me the same problem, how do you define two sourceMigration for one mapping?
This seems like a use case people can run into more often, not Flickr perse but combining multiple file fields into one, could you maybe add an example of how you would map this?
Comment #3
mikeryanDefining two source migrations for one mapping is just a matter of using an array:
Where you have separate MigrateDestinationFile migrations for Flickr references and regular files.
Comment #4
mikeryanNo further response.