浏览代码

[FrameworkBundle] Adding check for invalid form type for better exception message

Ryan Weaver 14 年之前
父节点
当前提交
fb4eb9c2e9
共有 1 个文件被更改,包括 3 次插入1 次删除
  1. 3 1
      src/Symfony/Bundle/FrameworkBundle/Form/ContainerAwareTypeLoader.php

+ 3 - 1
src/Symfony/Bundle/FrameworkBundle/Form/ContainerAwareTypeLoader.php

@@ -28,7 +28,9 @@ class ContainerAwareTypeLoader implements TypeLoaderInterface
 
     public function getType($identifier)
     {
-        // TODO check whether identifier exists
+        if (!isset($this->serviceIds[$identifier])) {
+            throw new \InvalidArgumentException(sprintf('The field type "%s" is not registered with the service container.', $identifier));
+        }
 
         return $this->container->get($this->serviceIds[$identifier]);
     }