Преглед изворни кода

[Form] Optimized code in Form to remove one event listener

Bernhard Schussek пре 14 година
родитељ
комит
e9cb19721a
1 измењених фајлова са 4 додато и 18 уклоњено
  1. 4 18
      src/Symfony/Component/Form/Form.php

+ 4 - 18
src/Symfony/Component/Form/Form.php

@@ -69,7 +69,6 @@ class Form extends Field implements \IteratorAggregate, FormInterface
     {
         $dispatcher->addListener(array(
             Events::postSetData,
-            Events::preBind,
             Events::filterSetData,
             Events::filterBoundClientData,
         ), $this);
@@ -178,9 +177,13 @@ class Form extends Field implements \IteratorAggregate, FormInterface
             }
         }
 
+        $this->extraFields = array();
+
         foreach ($data as $name => $value) {
             if ($this->has($name)) {
                 $this->fields[$name]->bind($value);
+            } else {
+                $this->extraFields[] = $name;
             }
         }
 
@@ -191,23 +194,6 @@ class Form extends Field implements \IteratorAggregate, FormInterface
         $event->setData($data);
     }
 
-    public function preBind(DataEvent $event)
-    {
-        $data = $event->getData();
-
-        if (empty($data)) {
-            $data = array();
-        }
-
-        $this->extraFields = array();
-
-        foreach ((array)$data as $name => $value) {
-            if (!$this->has($name)) {
-                $this->extraFields[] = $name;
-            }
-        }
-    }
-
     /**
      * Returns whether this form was bound with extra fields
      *