public function __construct(Configuration $config, MongoClient $conn, $db) { $this->config = $config; $this->cache = $config->getCache(); $this->mapper = $config->initialize($this); $this->conn = array('default' => $conn); $this->db = array('default' => $conn->selectDB($db)); $this->ns = array('default' => $config->getNamespace()); $this->mapper->setDatabases($this->db, $this->ns); if ($config->hasGenerated() || $config->isDevel()) { $this->ensureIndex(true); } }