1
0
mirror of synced 2025-01-31 04:21:44 +03:00

Added free( = false) support in Doctrine_Record and Doctrine_Collection (trunk)

This commit is contained in:
guilhermeblanco 2008-02-29 19:33:31 +00:00
parent a6a5192f47
commit 65442c7488
2 changed files with 35 additions and 6 deletions

View File

@ -912,6 +912,24 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
return $this;
}
public function free($deep = false)
{
foreach ($this->getData() as $key => $record) {
if ( ! ($record instanceof Doctrine_Null)) {
$record->free($deep);
}
}
$this->data = array();
if ($this->reference) {
$this->reference->free($deep);
$this->reference = null;
}
}
/**
* getIterator
* @return object ArrayIterator

View File

@ -1902,11 +1902,22 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
*/
public function free()
{
$this->_mapper->detach($this);
$this->_mapper->removeRecord($this);
$this->_data = array();
$this->_id = array();
$this->_references = array();
if ($this->_state != self::STATE_LOCKED) {
$this->_mapper->detach($this);
$this->_mapper->removeRecord($this);
$this->_data = array();
$this->_id = array();
if ($deep) {
foreach ($this->_references as $name => $reference) {
if ( ! ($reference instanceof Doctrine_Null)) {
$reference->free($deep);
}
}
}
$this->_references = array();
}
}
}