You are here

class MongoDebugCollection in MongoDB 6

Same name and namespace in other branches
  1. 7 mongodb.module \MongoDebugCollection

Class MongoDebugCollection wraps a MongoCollection with debug() instructions.

Hierarchy

Expanded class hierarchy of MongoDebugCollection

File

./mongodb.module, line 113
A library of common mechanisms for modules using MongoDB.

View source
class MongoDebugCollection {

  /**
   * Constructor.
   *
   * @param MongoCollection $collection
   *   The collection to wrap.
   */
  public function __construct(MongoCollection $collection) {
    $this->collection = $collection;
  }

  /**
   * Performs a find() on the original cursor, wrapping it in debug() calls.
   *
   * @param array $query
   *   The query criteria, as in the original MongoCollection::find().
   * @param array $fields
   *   The query result fields, as in the original MongoCollection::find().
   *
   * @return \MongoDebugCursor
   *   A new instance of a wrapped cursor.
   */
  public function find($query = array(), $fields = array()) {
    debug('find');
    debug($query);
    debug($fields);
    return new MongoDebugCursor($this->collection
      ->find($query, $fields));
  }

  /**
   * {@inheritdoc}
   */
  public function __call($name, $arguments) {
    debug($name);
    debug($arguments);
    return call_user_func_array(array(
      $this->collection,
      $name,
    ), $arguments);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
MongoDebugCollection::find public function Performs a find() on the original cursor, wrapping it in debug() calls.
MongoDebugCollection::__call public function
MongoDebugCollection::__construct public function Constructor.