. */ /** * Doctrine_Hydrate_Record * defines a record fetching strategy for Doctrine_Hydrate * * @package Doctrine * @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @category Object Relational Mapping * @link www.phpdoctrine.com * @since 1.0 * @version $Revision$ * @author Konsta Vesterinen */ class Doctrine_Hydrate_Record { protected $_collections = array(); protected $_records = array(); public function getElementCollection($component) { $coll = new Doctrine_Collection($component); $this->_collections[] = $coll; return $coll; } public function registerCollection($coll) { if ( ! is_object($coll)) { throw new Exception(); } $this->_collections[] = $coll; } public function getElement(array $data, $component) { $record = new $component(); $record->hydrate($data); $this->_records[] = $record; return $record; } public function flush() { // take snapshots from all initialized collections foreach (array_unique($this->_collections) as $key => $coll) { $coll->takeSnapshot(); } foreach ($this->_records as $record) { $record->state(Doctrine_Record::STATE_CLEAN); } } }