protected function initConnection($input, $output)
    {

        if (null !== $input->getOption('host')) {
            $connection['host'] = $input->getOption('host');
        }

        if (null !== $input->getOption('port')) {
            $connection['port'] = $input->getOption('port');
        }

        if (null !== $input->getOption('user')) {
            $connection['user'] = $input->getOption('user');
        }

        if (null !== $input->getOption('password')) {
            $connection['password'] = $input->getOption('password');
        }

        $doctrine_config = $this->bbapp->getConfig()->getDoctrineConfig();

        if(isset($connection['user']) && isset($connection['password'])) {
            if (isset($doctrine_config['dbal']['master'])) {
                $doctrine_config['dbal']['master'] = array_merge($doctrine_config['dbal']['master'], $connection);
            } else {
                $doctrine_config['dbal'] = array_merge($doctrine_config['dbal'], $connection);
            }
        }

        // DISABLE CACHE DOCTRINE
        unset($doctrine_config['dbal']['metadata_cache_driver']);
        unset($doctrine_config['dbal']['query_cache_driver']);

        if (!array_key_exists('proxy_ns', $doctrine_config['dbal'])) {
            $doctrine_config['dbal']['proxy_ns'] = 'Proxies';
        }

        if (!array_key_exists('proxy_dir', $doctrine_config['dbal'])) {
            $doctrine_config['dbal']['proxy_dir'] = $this->bbapp->getCacheDir() . '/' . 'Proxies';
        }

        try {
            $em = EntityManagerCreator::create($doctrine_config['dbal']);

            if (isset($doctrine_config['dbal']['master'])) {
                $em->getConnection()
                    ->connect('master');
            } else {
                $em->getConnection()
                    ->connect();
            }

        } catch (\Exception $e) {
            throw new DatabaseConnectionException(
                'Unable to connect to the database.', 0, $e);
        }

        return $em;
    }
protected function initConnection($input, $output)
    {

        if (null !== $input->getOption('host')) {
            $connection['host'] = $input->getOption('host');
        }

        if (null !== $input->getOption('port')) {
            $connection['port'] = $input->getOption('port');
        }

        if (null !== $input->getOption('user')) {
            $connection['user'] = $input->getOption('user');
        }

        if (null !== $input->getOption('password')) {
            $connection['password'] = $input->getOption('password');
        }

        $doctrine_config = $this->bbapp->getConfig()->getDoctrineConfig();

        if(isset($connection['user']) && isset($connection['password'])) {
            if (isset($doctrine_config['dbal']['master'])) {
                $doctrine_config['dbal']['master'] = array_merge($doctrine_config['dbal']['master'], $connection);
            } else {
                $doctrine_config['dbal'] = array_merge($doctrine_config['dbal'], $connection);
            }
        }

        // DISABLE CACHE DOCTRINE
        unset($doctrine_config['dbal']['metadata_cache_driver']);
        unset($doctrine_config['dbal']['query_cache_driver']);

        if (!array_key_exists('proxy_ns', $doctrine_config['dbal'])) {
            $doctrine_config['dbal']['proxy_ns'] = 'Proxies';
        }

        if (!array_key_exists('proxy_dir', $doctrine_config['dbal'])) {
            $doctrine_config['dbal']['proxy_dir'] = $this->bbapp->getCacheDir() . '/' . 'Proxies';
        }

        try {
            $em = EntityManagerCreator::create($doctrine_config['dbal']);

            if (isset($doctrine_config['dbal']['master'])) {
                $em->getConnection()
                    ->connect('master');
            } else {
                $em->getConnection()
                    ->connect();
            }

        } catch (\Exception $e) {
            throw new DatabaseConnectionException(
                'Unable to connect to the database.', 0, $e);
        }

        return $em;
    }
protected function initConnection ( $ input , $ output ) { if ( null !== $ input -> getOption ( 'host' ) ) { $ connection [ 'host' ] = $ input -> getOption ( 'host' ) ; } if ( null !== $ input -> getOption ( 'port' ) ) { $ connection [ 'port' ] = $ input -> getOption ( 'port' ) ; } if ( null !== $ input -> getOption ( 'user' ) ) { $ connection [ 'user' ] = $ input -> getOption ( 'user' ) ; } if ( null !== $ input -> getOption ( 'password' ) ) { $ connection [ 'password' ] = $ input -> getOption ( 'password' ) ; } $ doctrine_config = $ this -> bbapp -> getConfig ( ) -> getDoctrineConfig ( ) ; if ( isset ( $ connection [ 'user' ] ) && isset ( $ connection [ 'password' ] ) ) { if ( isset ( $ doctrine_config [ 'dbal' ] [ 'master' ] ) ) { $ doctrine_config [ 'dbal' ] [ 'master' ] = array_merge ( $ doctrine_config [ 'dbal' ] [ 'master' ] , $ connection ) ; } else { $ doctrine_config [ 'dbal' ] = array_merge ( $ doctrine_config [ 'dbal' ] , $ connection ) ; } } // DISABLE CACHE DOCTRINE unset ( $ doctrine_config [ 'dbal' ] [ 'metadata_cache_driver' ] ) ; unset ( $ doctrine_config [ 'dbal' ] [ 'query_cache_driver' ] ) ; if ( ! array_key_exists ( 'proxy_ns' , $ doctrine_config [ 'dbal' ] ) ) { $ doctrine_config [ 'dbal' ] [ 'proxy_ns' ] = 'Proxies' ; } if ( ! array_key_exists ( 'proxy_dir' , $ doctrine_config [ 'dbal' ] ) ) { $ doctrine_config [ 'dbal' ] [ 'proxy_dir' ] = $ this -> bbapp -> getCacheDir ( ) . '/' . 'Proxies' ; } try { $ em = EntityManagerCreator :: create ( $ doctrine_config [ 'dbal' ] ) ; if ( isset ( $ doctrine_config [ 'dbal' ] [ 'master' ] ) ) { $ em -> getConnection ( ) -> connect ( 'master' ) ; } else { $ em -> getConnection ( ) -> connect ( ) ; } } catch ( \ Exception $ e ) { throw new DatabaseConnectionException ( 'Unable to connect to the database.' , 0 , $ e ) ; } return $ em ; }
Initiate doctrine connection for the Command on master database if its configure

@param object       $input       The input option of command
@param object       $output      The output of command

@throws \DatabaseConnectionException When Unable to connect to database
Initiate doctrine connection for the Command on master database if its configure