Components/DB/NoSQL/Drivers/MongoDB/MongoDBDriver.php
public function connect()
    {
        if (!isset($this->configuration['host']) || !isset($this->configuration['database'])) {
            throw new NoSQLDriverException('Can not connect to MongoDB because configuration for this driver was not provided.');
        }

        try {
            $this->connection = new \MongoDB\Client(
                $this->configuration['host'],
                $this->configuration['options'],
                $this->configuration['driver_options']
            );
        } catch (\Exception $e) {
            throw new NoSQLDriverException('Can not connect to storage because of: '.$e->getMessage(), $e->getCode(), $e);
        }

        $this->db = $this->connection->selectDatabase($this->configuration['database']);

        return $this->connection;
    }
public function connect()
    {
        if (!isset($this->configuration['host']) || !isset($this->configuration['database'])) {
            throw new NoSQLDriverException('Can not connect to MongoDB because configuration for this driver was not provided.');
        }

        try {
            $this->connection = new \MongoDB\Client(
                $this->configuration['host'],
                $this->configuration['options'],
                $this->configuration['driver_options']
            );
        } catch (\Exception $e) {
            throw new NoSQLDriverException('Can not connect to storage because of: '.$e->getMessage(), $e->getCode(), $e);
        }

        $this->db = $this->connection->selectDatabase($this->configuration['database']);

        return $this->connection;
    }
public function connect ( ) { if ( ! isset ( $ this -> configuration [ 'host' ] ) || ! isset ( $ this -> configuration [ 'database' ] ) ) { throw new NoSQLDriverException ( 'Can not connect to MongoDB because configuration for this driver was not provided.' ) ; } try { $ this -> connection = new \ MongoDB \ Client ( $ this -> configuration [ 'host' ] , $ this -> configuration [ 'options' ] , $ this -> configuration [ 'driver_options' ] ) ; } catch ( \ Exception $ e ) { throw new NoSQLDriverException ( 'Can not connect to storage because of: ' . $ e -> getMessage ( ) , $ e -> getCode ( ) , $ e ) ; } $ this -> db = $ this -> connection -> selectDatabase ( $ this -> configuration [ 'database' ] ) ; return $ this -> connection ; }
Connect to the mongoDatabase.

@return \MongoDB\Client

@throws \Smartbox\Integration\FrameworkBundle\Components\DB\NoSQL\Exceptions\NoSQLDriverException
Connect to the mongoDatabase .