]> git.andy128k.dev Git - ipf.git/commitdiff
minor simplifications
authorAndrey Kutejko <andy128k@gmail.com>
Sun, 11 Aug 2013 11:23:18 +0000 (14:23 +0300)
committerAndrey Kutejko <andy128k@gmail.com>
Sun, 11 Aug 2013 11:23:18 +0000 (14:23 +0300)
ipf/command/fixtures.php
ipf/form/field.php

index 22266da90749c12da9b77a17de323b0f72543ff5..0cc2c9cbb48cf86363cd58e68af248c73e856a74 100644 (file)
@@ -36,14 +36,19 @@ class IPF_Command_Fixtures
             echo "Loading $modelClass ";
             $table = IPF_ORM::getTable($modelClass);
             $table->getConnection()->beginTransaction();
+
+            $query = $table
+                ->createQuery()
+                ->limit(1);
+            foreach ($key as $k)
+                $query->addWhere($k . ' = ?');
+
             foreach ($records as $record) {
-                $query = $table
-                    ->createQuery()
-                    ->limit(1);
+                $params = array();
                 foreach ($key as $k)
-                    $query->addWhere($k . ' = ?', array($record[$k]));
+                    $params[] = $record[$k];
 
-                $model = $query->execute();
+                $model = $query->execute($params);
                 if ($model)
                     $model = $model[0];
                 else
index bd87d679ca3037d43346945cafa490704c1b7d00..85d225f92f8db0f8aab9f1a06f2b516a3b2d41f8 100644 (file)
@@ -17,19 +17,18 @@ class IPF_Form_Field
 
     function __construct($params=array())
     {
+        $widget_attrs = ArrayTools::pop($params, 'widget_attrs', array());
+
         $default = array();
         foreach ($params as $key=>$in) {
-            if ($key !== 'widget_attrs')
-                if (isset($this->$key))
-                    $default[$key] = $this->$key;
+            if (isset($this->$key))
+                $default[$key] = $this->$key;
         }
         $m = array_merge($default, $params);
         foreach ($params as $key=>$in) {
-            if ($key !== 'widget_attrs')
-                $this->$key = $m[$key];
+            $this->$key = $m[$key];
         }
 
-        $widget_attrs = isset($params['widget_attrs']) ? $params['widget_attrs'] : array();
         $this->widget = $this->createWidget($widget_attrs);
     }