/** * Get raw edmsMongoDb instance * * @return edmsMongoDb */ public static function instance($connectionId) { if (!isset(self::$_instance)) { self::$_instance = array(); } if (!isset(self::$_instance[$connectionId])) { $component = Yii::app()->getComponent($connectionId); if ($component instanceof EDMSConnection) { self::$_instance[$connectionId] = $component; } else { //use YiiMongoDbSuite EMongoDB config if ($component instanceof EMongoDB) { $connection = new EDMSConnection(); $connection->server = $component->connectionString; $connection->dbName = $component->dbName; if ($component->autoConnect == false) { $connection->options['connect'] = false; } self::$_instance[$connectionId] = $connection; } else { throw new EDMSException("Invalid connectionId: {$connectionId}"); } } } return self::$_instance[$connectionId]; }