You are here

class MongoDebugCollection in MongoDB 7

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

Hierarchy

Expanded class hierarchy of MongoDebugCollection

File

./mongodb.module, line 153
Contains the main module connecting Drupal to MongoDB.

View source
class MongoDebugCollection {

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

  /**
   * A decorator for the MongoCollection::find() method adding debug info.
   *
   * @param array|null $query
   *   A MongoCollection;:find()-compatible query array.
   * @param array|null $fields
   *   A MongoCollection;:find()-compatible fields array.
   *
   * @return \MongoDebugCursor
   *   A debug cursor wrapping the decorated find() results.
   */
  public function find($query = array(), $fields = array()) {
    debug('find');
    debug($query);
    debug($fields);
    return new MongoDebugCursor($this->collection
      ->find($query, $fields));
  }

  /**
   * Decorates the standard __call() by debug()-ing its arguments.
   *
   * @param string $name
   *   The name of the called method.
   * @param array $arguments
   *   The arguments for the decorated __call().
   *
   * @return mixed
   *   The result of the decorated __call().
   */
  public function __call($name, array $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 A decorator for the MongoCollection::find() method adding debug info.
MongoDebugCollection::__call public function Decorates the standard __call() by debug()-ing its arguments.
MongoDebugCollection::__construct public function Constructor.