Migrate callbacks() with addFieldMapping for destination_dir i want to switch the destination_dir in a custom file migration class derived from DrupalFile6Migration. The DrupalFile6Migration class is provided by the migrate_d2d module.

For this purpose i think it's necessary to use callbacks for field mappings like it's described here:
https://www.drupal.org/node/1133448

I use successful a callback with the field mapping for destination_file in the file migration:
    

class FileMigration extends DrupalFile6Migration {
  public function __construct(array $arguments) {
    parent::__construct($arguments);
    $this-&gt;addFieldMapping('destination_file', 'filepath')
      -&gt;callbacks(array($this, 'myPath'));
  ...
  protected function myPath($uri) {
    // do stuff
  }
...


But when i try do do this with the destination_dir i can't get success.
XDebug shows, that myDestination() is never called:

  this-&gt;addFieldMapping('destination_dir')
    -&gt;callbacks('myDestination');
  ...
  protected function myDestination() {
    if(...) {
       return 'private://';
    }
    else {
      return 'public://';
    }
  }


But i can change the destination_dir with defaultValue, e.g.:

  this-&gt;addFieldMapping('destination_dir')
    -&gt;defaultValue('private://');


Any suggestions, knowings if callbacks() in combination with destination_dir is perhaps not possible?
Maybe you can use file_class like this

$this-&gt;addFieldMapping('field_yourimage_field', 'fidsarray');
$this-&gt;addFieldMapping('field_yourimage_field:file_class')
-&gt;defaultValue('MigrateFileFid');


The you have to implement prepare row to get the managed file fids you want to import like this

public function prepareRow($current_row) {
 if (parent::prepareRow($current_row) === FALSE) {
  return FALSE;
 }
 //sample code to get the file ids. it may be different in your case
 $fidsarray= array(); 
 $fidsarray = explode(",", $current_row-&gt;columnwith_file_ids_comma separated);  
 $current_row-&gt;fidsarray=$fidsarray;
}


if you dont have managed files and therefore fids available other options can be used too.
See https://www.drupal.org/node/1540106