Changeset 3122

Show
Ignore:
Timestamp:
04/14/08 20:46:22 (3 months ago)
Author:
pmjones
Message:

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).

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Solar/Filter.php

    r3094 r3122  
    559559        } 
    560560         
    561         // loop through each data element 
    562         foreach ($this->_data as $key => $val) { 
    563              
    564             // keep the key name 
    565             $this->_data_key = $key; 
    566              
     561        // which elements to filter? 
     562        $keys = array_keys($this->_chain_filters); 
     563         
     564        // loop through each element to be filtered 
     565        foreach ($keys as $key) { 
    567566            // if it's already invalid (from "require" above) 
    568567            // then skip it.  this avoids multiple validation 
     
    570569            if (! empty($this->_chain_invalid[$key])) { 
    571570                continue; 
     571            } else { 
     572                // run the filters for the data element 
     573                $this->_applyChain($key); 
    572574            } 
    573              
    574             // are there filters on this key? 
    575             if (empty($this->_chain_filters[$key])) { 
    576                 continue; 
    577             } 
    578              
    579             // is this key required? 
    580             if (! empty($this->_chain_require[$key])) { 
    581                 $this->setRequire(true); 
    582             } else { 
    583                 $this->setRequire(false); 
    584             } 
    585              
    586             // run the filters for each data element 
    587             $this->_applyChain($key); 
    588575        } 
    589576         
     
    606593    protected function _applyChain($key) 
    607594    { 
    608         foreach ($this->_chain_filters[$key] as $params) { 
     595        // keep the key name 
     596        $this->_data_key = $key; 
     597         
     598        // is this key required? 
     599        if (! empty($this->_chain_require[$key])) { 
     600            $this->setRequire(true); 
     601        } else { 
     602            $this->setRequire(false); 
     603        } 
     604         
     605        foreach ((array) $this->_chain_filters[$key] as $params) { 
    609606             
    610607            // take the method name off the top of the params ...