소스 검색

[Form] added a way to register a Form extension after creation of the FormFactory

Fabien Potencier 14 년 전
부모
커밋
2b8c7f84b5
1개의 변경된 파일6개의 추가작업 그리고 6개의 파일을 삭제
  1. 6 6
      src/Symfony/Component/Form/FormFactory.php

+ 6 - 6
src/Symfony/Component/Form/FormFactory.php

@@ -14,7 +14,6 @@ namespace Symfony\Component\Form;
 use Symfony\Component\Form\Guess\TypeGuesserInterface;
 use Symfony\Component\Form\Guess\Guess;
 use Symfony\Component\Form\Exception\FormException;
-use Symfony\Component\Form\Exception\UnexpectedTypeException;
 
 class FormFactory implements FormFactoryInterface
 {
@@ -24,15 +23,16 @@ class FormFactory implements FormFactoryInterface
 
     private $guesser;
 
-    public function __construct(array $extensions)
+    public function __construct(array $extensions = array())
     {
         foreach ($extensions as $extension) {
-            if (!$extension instanceof FormExtensionInterface) {
-                throw new UnexpectedTypeException($extension, 'Symfony\Component\Form\FormExtensionInterface');
-            }
+            $this->addExtension($extension);
         }
+    }
 
-        $this->extensions = $extensions;
+    public function addExtension(FormExtensionInterface $extension)
+    {
+        $this->extensions[] = $extension;
     }
 
     private function loadGuesser()