/** * Initializes the migration. * This method will set {@see \rock\mongodb\Migration::$connection} to be the 'mongodb' application component, if it is null. */ public function init() { $this->connection = Instance::ensure($this->connection, Connection::className()); }
/** * Returns the Mongo collection for this query. * * @param ConnectionInterface $connection Mongo connection. * @return Collection collection instance. */ public function getCollection(ConnectionInterface $connection = null) { $this->connection = isset($connection) ? $connection : Instance::ensure($this->connection, Connection::className()); $this->calculateCacheParams($this->connection); return $this->connection->getCollection($this->from); }
/** * Returns the Mongo connection used by this AR class. * By default, the "mongodb" application component is used as the Mongo connection. * You may override this method if you want to use a different database connection. * @return Connection the database connection used by this AR class. */ public static function getConnection() { return Instance::ensure('mongodb', Connection::className()); }