lib/Doctrine/MongoDB/Connection.php
public function initialize()
    {
        if ($this->mongoClient !== null) {
            return;
        }

        if ($this->eventManager->hasListeners(Events::preConnect)) {
            $this->eventManager->dispatchEvent(Events::preConnect, new EventArgs($this));
        }

        $server = $this->server ?: 'mongodb://localhost:27017';
        $options = $this->options;

        $options = isset($options['timeout']) ? $this->convertConnectTimeout($options) : $options;
        $options = isset($options['wTimeout']) ? $this->convertWriteTimeout($options) : $options;

        $this->mongoClient = $this->retry(function() use ($server, $options) {
            return new \MongoClient($server, $options, $this->driverOptions);
        });

        if ($this->eventManager->hasListeners(Events::postConnect)) {
            $this->eventManager->dispatchEvent(Events::postConnect, new EventArgs($this));
        }
    }
public function initialize()
    {
        if ($this->mongoClient !== null) {
            return;
        }

        if ($this->eventManager->hasListeners(Events::preConnect)) {
            $this->eventManager->dispatchEvent(Events::preConnect, new EventArgs($this));
        }

        $server = $this->server ?: 'mongodb://localhost:27017';
        $options = $this->options;

        $options = isset($options['timeout']) ? $this->convertConnectTimeout($options) : $options;
        $options = isset($options['wTimeout']) ? $this->convertWriteTimeout($options) : $options;

        $this->mongoClient = $this->retry(function() use ($server, $options) {
            return new \MongoClient($server, $options, $this->driverOptions);
        });

        if ($this->eventManager->hasListeners(Events::postConnect)) {
            $this->eventManager->dispatchEvent(Events::postConnect, new EventArgs($this));
        }
    }
public function initialize ( ) { if ( $ this -> mongoClient !== null ) { return ; } if ( $ this -> eventManager -> hasListeners ( Events :: preConnect ) ) { $ this -> eventManager -> dispatchEvent ( Events :: preConnect , new EventArgs ( $ this ) ) ; } $ server = $ this -> server ? : 'mongodb://localhost:27017' ; $ options = $ this -> options ; $ options = isset ( $ options [ 'timeout' ] ) ? $ this -> convertConnectTimeout ( $ options ) : $ options ; $ options = isset ( $ options [ 'wTimeout' ] ) ? $ this -> convertWriteTimeout ( $ options ) : $ options ; $ this -> mongoClient = $ this -> retry ( function ( ) use ( $ server , $ options ) { return new \ MongoClient ( $ server , $ options , $ this -> driverOptions ) ; } ) ; if ( $ this -> eventManager -> hasListeners ( Events :: postConnect ) ) { $ this -> eventManager -> dispatchEvent ( Events :: postConnect , new EventArgs ( $ this ) ) ; } }
Construct the wrapped MongoClient instance if necessary.

This method will dispatch preConnect and postConnect events.
Construct the wrapped MongoClient instance if necessary .