瀏覽代碼

[DoctrineBundle] removed redundant check

Fabien Potencier 14 年之前
父節點
當前提交
bd608c8bfa
共有 1 個文件被更改,包括 2 次插入10 次删除
  1. 2 10
      src/Symfony/Bundle/DoctrineBundle/Registry.php

+ 2 - 10
src/Symfony/Bundle/DoctrineBundle/Registry.php

@@ -32,15 +32,7 @@ class Registry
         $this->container = $container;
         $this->connections = $connections;
         $this->entityManagers = $entityManagers;
-
-        if (!isset($this->connections[$defaultConnection])) {
-            throw new \LogicException(sprintf('Default connection "%s" is not defined.', $defaultConnection));
-        }
         $this->defaultConnection = $defaultConnection;
-
-        if (!isset($this->entityManagers[$defaultEntityManager])) {
-            throw new \LogicException(sprintf('Default entity manager "%s" is not defined.', $defaultEntityManager));
-        }
         $this->defaultEntityManager = $defaultEntityManager;
     }
 
@@ -64,7 +56,7 @@ class Registry
     public function getConnection($name = null)
     {
         if (null === $name) {
-            return $this->container->get($this->connections[$this->defaultConnection]);
+            $name = $this->defaultConnection;
         }
 
         if (!isset($this->connections[$name])) {
@@ -104,7 +96,7 @@ class Registry
     public function getEntityManager($name = null)
     {
         if (null === $name) {
-            return $this->container->get($this->entityManagers[$this->defaultEntityManager]);
+            $name = $this->defaultEntityManager;
         }
 
         if (!isset($this->entityManagers[$name])) {