[Solar-svn] Revision 3122
pmjones at solarphp.com
pmjones at solarphp.com
Mon Apr 14 20:46:29 CDT 2008
Solar_Filter
------------
* [REF] Moved portions of applyChain() into support method _applyChain() to
keep the logic in one place.
* [CHG] To avoid lazy-loading related elements in Record objects, the applyChain()
method now loops through the chain-filter keys, instead of hitting every
single data element regardless of whether or not it has filters on it. This
is a change back to the original implementation from revision 2766 in Sep 2008;
not sure why I swapped it to look at the data elements directly in the next
revision after that (2793).
Modified: trunk/Solar/Filter.php
===================================================================
--- trunk/Solar/Filter.php 2008-04-15 01:26:31 UTC (rev 3121)
+++ trunk/Solar/Filter.php 2008-04-15 01:46:22 UTC (rev 3122)
@@ -558,33 +558,20 @@
}
}
- // loop through each data element
- foreach ($this->_data as $key => $val) {
-
- // keep the key name
- $this->_data_key = $key;
-
+ // which elements to filter?
+ $keys = array_keys($this->_chain_filters);
+
+ // loop through each element to be filtered
+ foreach ($keys as $key) {
// if it's already invalid (from "require" above)
// then skip it. this avoids multiple validation
// messages on missing elements.
if (! empty($this->_chain_invalid[$key])) {
continue;
- }
-
- // are there filters on this key?
- if (empty($this->_chain_filters[$key])) {
- continue;
- }
-
- // is this key required?
- if (! empty($this->_chain_require[$key])) {
- $this->setRequire(true);
} else {
- $this->setRequire(false);
+ // run the filters for the data element
+ $this->_applyChain($key);
}
-
- // run the filters for each data element
- $this->_applyChain($key);
}
// return the validation status; if not empty, at least one of the
@@ -605,7 +592,17 @@
*/
protected function _applyChain($key)
{
- foreach ($this->_chain_filters[$key] as $params) {
+ // keep the key name
+ $this->_data_key = $key;
+
+ // is this key required?
+ if (! empty($this->_chain_require[$key])) {
+ $this->setRequire(true);
+ } else {
+ $this->setRequire(false);
+ }
+
+ foreach ((array) $this->_chain_filters[$key] as $params) {
// take the method name off the top of the params ...
$method = array_shift($params);
More information about the Solar-svn
mailing list