You are here

public function AbstractManagerRegistry::getConnection in Plug 7

Gets the named connection.

Parameters

string $name The connection name (null for the default one).:

Return value

object

Overrides ConnectionRegistry::getConnection

File

lib/doctrine/common/lib/Doctrine/Common/Persistence/AbstractManagerRegistry.php, line 118

Class

AbstractManagerRegistry
Abstract implementation of the ManagerRegistry contract.

Namespace

Doctrine\Common\Persistence

Code

public function getConnection($name = null) {
  if (null === $name) {
    $name = $this->defaultConnection;
  }
  if (!isset($this->connections[$name])) {
    throw new \InvalidArgumentException(sprintf('Doctrine %s Connection named "%s" does not exist.', $this->name, $name));
  }
  return $this
    ->getService($this->connections[$name]);
}