Created
February 3, 2011 06:54
-
-
Save michaeltwofish/809141 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Applies a callback to a copy of all data in the collection | |
* and returns the result. | |
* | |
* Overriden to load any data that has not yet been loaded. | |
* | |
* @param callback $filter The filter to apply. | |
* @param array $options The available options are: | |
* - `'collect'`: If `true`, the results will be returned wrapped | |
* in a new Collection object or subclass. | |
* @return array|object The filtered data. | |
*/ | |
public function map($filter, array $options = array()) { | |
if (!$this->closed()) { | |
while($this->next()) {} | |
} | |
$data = parent::map($filter, $options); | |
if ($options['collect']) { | |
$data->_model = $this->_model; | |
} | |
return $data; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment