Added free( = false) support in Doctrine_Record and Doctrine_Collection (trunk)
This commit is contained in:
parent
a6a5192f47
commit
65442c7488
@ -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
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user