You are here

public function MigrateSourceMongoDB::performRewind in Migrate 7.2

Implementation of MigrateSource::performRewind().

Return value

void

File

plugins/sources/mongodb.inc, line 94
Define a MigrateSource for importing from MongoDB connections

Class

MigrateSourceMongoDB
Implementation of MigrateSource, to handle imports from MongoDB connections.

Code

public function performRewind() {
  $keys = $this
    ->getSourceKeyNameAndType();

  // If we have an existing idlist we use it.
  if ($this->idList) {
    foreach ($this->idList as $key => $id) {

      // Try make new ObjectID.
      $this->idList[$key] = $this
        ->getMongoId($id, $keys);
    }
    $this->query[$keys[0]['name']]['$in'] = $this->idList;
  }
  migrate_instrument_start('MigrateSourceMongoDB execute');
  try {
    $this->cursor = $this->collection
      ->find($this->query)
      ->sort($this->sort);
    $this->cursor
      ->timeout(-1);
  } catch (MongoCursorException $e) {
    Migration::displayMessage($e
      ->getMessage(), 'error');
  }
  migrate_instrument_stop('MigrateSourceMongoDB execute');
}