You are here

public function AbstractManagerRegistry::getConnection in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/doctrine/common/lib/Doctrine/Common/Persistence/AbstractManagerRegistry.php \Doctrine\Common\Persistence\AbstractManagerRegistry::getConnection()

Gets the named connection.

Parameters

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

Return value

object

Overrides ConnectionRegistry::getConnection

File

vendor/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]);
}