Doctrine\Common\Persistence\AbstractManagerRegistry::getConnection PHP Метод

getConnection() публичный Метод

public getConnection ( $name = null )
    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]);
    }

Usage Example

Пример #1
0
 /**
  * Construct AclFilter
  *
  * @param AbstractManagerRegistry  $doctrine
  * @param SecurityContextInterface $securityContext
  * @param array                    $options
  */
 public function __construct(AbstractManagerRegistry $doctrine, SecurityContextInterface $securityContext, array $options = array())
 {
     $this->em = $doctrine->getManager();
     $this->securityContext = $securityContext;
     $this->aclConnection = $doctrine->getConnection('default');
     list($this->aclWalker, $this->roleHierarchy) = $options;
 }