You are here

protected function Migration::createStubWrapper in Migrate 6.2

Same name and namespace in other branches
  1. 7.2 includes/migration.inc \Migration::createStubWrapper()

If stub creation is enabled, try to create a stub and save the mapping.

File

includes/migration.inc, line 1283
Defines the base class for import/rollback processes.

Class

Migration
The base class for all import objects. This is where most of the smarts of the migrate module resides. Migrations are created by deriving from this class, and in the constructor (after calling parent::__construct()) initializing at a minimum the name,…

Code

protected function createStubWrapper(array $source_key, $migration = NULL) {
  if (method_exists($this, 'createStub')) {
    $destids = $this
      ->createStub($migration, $source_key);
    if ($destids) {

      // Fake a data row with the source key in it
      $map_source_key = $this->map
        ->getSourceKey();
      $data_row = new stdClass();
      $i = 0;
      foreach ($map_source_key as $key => $definition) {
        $data_row->{$key} = $source_key[$i++];
      }
      $this->map
        ->saveIDMapping($data_row, $destids, MigrateMap::STATUS_NEEDS_UPDATE, $this->defaultRollbackAction);
    }
  }
  else {
    $destids = NULL;
  }
  return $destids;
}