Browse Source

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

This reverts commit 2b8c7f84b502007e2d4c8b1e62254492f88badcd.
Fabien Potencier 14 năm trước cách đây
mục cha
commit
f251eab92f
1 tập tin đã thay đổi với 6 bổ sung6 xóa
  1. 6 6
      src/Symfony/Component/Form/FormFactory.php

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

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