[Solar-svn] Revision 2668

pmjones at solarphp.com pmjones at solarphp.com
Wed Aug 8 15:06:54 CDT 2007


Branch: Solar_Filter:

* [FIX] Method getData() now returns reference properly

* [CHG] Now using isset() instead of array_key_exists() when checking chain_require, because the ArrayAccess interface used by Solar_Struct doesn't honor array keys properly

* [FIX] When chain_require doesn't find a required element, now uses chainLocale() method properly



Modified: branches/orm/Solar/Filter.php
===================================================================
--- branches/orm/Solar/Filter.php	2007-08-07 21:56:52 UTC (rev 2667)
+++ branches/orm/Solar/Filter.php	2007-08-08 20:06:54 UTC (rev 2668)
@@ -453,10 +453,11 @@
     public function &getData($key = null)
     {
         if ($key === null) {
-            return $this->_data;
+            $data =& $this->_data;
         } elseif (array_key_exists($key, $this->_data)) {
-            return $this->_data[$key];
+            $data =& $this->_data[$key];
         }
+        return $data;
     }
     
     /**
@@ -528,20 +529,18 @@
             
             // "blank" means the key does not exist in the data, or that it
             // validates as a blank value
-            $blank = ! array_key_exists($key, $this->_data) ||
+            $blank = ! isset($this->_data[$key]) ||
                      $this->validateBlank($this->_data[$key]);
             
             // is it blank?
             if ($blank) {
-                $msg = $this->_chain_locale_object->locale(
-                    'VALIDATE_NOT_BLANK'
-                );
+                $msg = $this->_chainLocale('VALIDATE_NOT_BLANK');
                 $this->_chain_invalid[$key][] = $msg;
             }
         }
         
         // loop through each data element
-        foreach ($this->_data as $key => &$val) {
+        foreach ($this->_data as $key => $val) {
             
             // keep the key name
             $this->_data_key = $key;
@@ -574,7 +573,7 @@
                 $type = strtolower(substr($method, 0, 8));
                 if ($type == 'sanitize') {
                     // retain the sanitized value
-                    $val = $result;
+                    $this->_data[$key] = $result;
                 } elseif ($type == 'validate' && ! $result) {
                     // a validation method failed; use the method name as
                     // the locale translation key, converting from camelCase
@@ -586,7 +585,8 @@
         
         // return the validation status; if not empty, at least one of the
         // data elements was not valid.
-        return empty($this->_chain_invalid);
+        $result = empty($this->_chain_invalid);
+        return $result;
     }
     
     /**




More information about the Solar-svn mailing list