/** * @param $connection * @param array $config * @throws Exception\RuntimeException */ public function __construct($connection, $config = []) { // @codeCoverageIgnoreStart if (!extension_loaded('mongo') || !class_exists('MongoClient') || version_compare(MongoClient::VERSION, '1.4.1', '<')) { throw new Exception\RuntimeException('The Mongo Driver v1.4.1 required for this adapter to work'); } // @codeCoverageIgnoreEnd parent::__construct($connection, $config); }
/** * @param null $connection * @param array $config * @throws \yii\base\InvalidConfigException * @throws \yii\mongodb\Exception */ public function __construct($connection = null, $config = []) { if ($connection === null) { if ($this->connection !== null && \Yii::$app->has($this->connection)) { $db = \Yii::$app->get($this->connection); if (!$db instanceof \yii\mongodb\Connection) { throw new \yii\base\InvalidConfigException('Connection component must implement \\yii\\mongodb\\Connection.'); } $connection = $db->getDatabase()->mongoDb; } } else { $connection = new \yii\mongodb\Connection(['dsn' => $this->dsn]); $connection = $connection->getDatabase()->mongoDb; } parent::__construct($connection, $config); }
/** * @param $connection * @param array $config * @throws Exception\RuntimeException */ public function __construct($connection, $config = []) { // @codeCoverageIgnoreStart if (!(extension_loaded('mongodb') || extension_loaded('mongo')) || !class_exists(MongoClient::class) || version_compare(MongoClient::VERSION, '1.4.1', '<')) { throw new Exception\RuntimeException('The MongoAdapter requires either the Mongo Driver v1.4.1 or ' . 'ext/mongodb + the alcaeus/mongo-php-adapter package (which provides ' . 'backwards compatibility for ext/mongo classes)'); } // @codeCoverageIgnoreEnd parent::__construct($connection, $config); }