You are here

public function MigrateSourceMongoDB::__toString in Migrate 7.2

Return a string representing the source query.

Return value

string

File

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

Class

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

Code

public function __toString() {
  if (is_null($this->cursor)) {
    $this->cursor = $this->collection
      ->find($this->query)
      ->sort($this->sort);
    $this->cursor
      ->timeout(-1);
  }
  $query_info = $this->cursor
    ->info();
  $query = 'query:    ' . drupal_json_encode($query_info['query']['$query']);
  $sort = 'order by: ' . drupal_json_encode($query_info['query']['$orderby']);
  $fields = 'fields:   ' . drupal_json_encode($query_info['fields']);
  return $query . PHP_EOL . $sort . PHP_EOL . $fields . PHP_EOL;
}