public function getConnection()
    {
        $repositoryConfig = $this->repositoryConfigurationProvider->getRepositoryConfig();
        // Taking provided connection name if any.
        // Otherwise, just fallback to the default connection.

        if (isset($repositoryConfig['search']['connection'])) {
            $doctrineConnectionId = sprintf('doctrine.dbal.%s_connection', $repositoryConfig['search']['connection']);
        } else {
            // "database_connection" is an alias to the default connection, set up by DoctrineBundle.
            $doctrineConnectionId = 'database_connection';
        }

        if (!$this->container->has($doctrineConnectionId)) {
            throw new InvalidArgumentException(
                "Invalid Doctrine connection '{$repositoryConfig['search']['connection']}' for repository '{$repositoryConfig['alias']}'." .
                'Valid connections are ' . implode(', ', array_keys($this->container->getParameter('doctrine.connections')))
            );
        }

        return $this->container->get($doctrineConnectionId);
    }
public function getConnection()
    {
        $repositoryConfig = $this->repositoryConfigurationProvider->getRepositoryConfig();
        // Taking provided connection name if any.
        // Otherwise, just fallback to the default connection.

        if (isset($repositoryConfig['search']['connection'])) {
            $doctrineConnectionId = sprintf('doctrine.dbal.%s_connection', $repositoryConfig['search']['connection']);
        } else {
            // "database_connection" is an alias to the default connection, set up by DoctrineBundle.
            $doctrineConnectionId = 'database_connection';
        }

        if (!$this->container->has($doctrineConnectionId)) {
            throw new InvalidArgumentException(
                "Invalid Doctrine connection '{$repositoryConfig['search']['connection']}' for repository '{$repositoryConfig['alias']}'." .
                'Valid connections are ' . implode(', ', array_keys($this->container->getParameter('doctrine.connections')))
            );
        }

        return $this->container->get($doctrineConnectionId);
    }
public function getConnection ( ) { $ repositoryConfig = $ this -> repositoryConfigurationProvider -> getRepositoryConfig ( ) ; // Taking provided connection name if any. // Otherwise, just fallback to the default connection. if ( isset ( $ repositoryConfig [ 'search' ] [ 'connection' ] ) ) { $ doctrineConnectionId = sprintf ( 'doctrine.dbal.%s_connection' , $ repositoryConfig [ 'search' ] [ 'connection' ] ) ; } else { // "database_connection" is an alias to the default connection, set up by DoctrineBundle. $ doctrineConnectionId = 'database_connection' ; } if ( ! $ this -> container -> has ( $ doctrineConnectionId ) ) { throw new InvalidArgumentException ( "Invalid Doctrine connection '{$repositoryConfig['search']['connection']}' for repository '{$repositoryConfig['alias']}'." . 'Valid connections are ' . implode ( ', ' , array_keys ( $ this -> container -> getParameter ( 'doctrine.connections' ) ) ) ) ; } return $ this -> container -> get ( $ doctrineConnectionId ) ; }
Returns database connection used by database handler.

@throws \InvalidArgumentException

@return \Doctrine\DBAL\Connection
Returns database connection used by database handler .