[2.0] Ensuring that PersistentCollection instances that are injected by Doctrine can be transparently serialized.
This commit is contained in:
parent
cfae81e11a
commit
0a81ae773d
@ -117,6 +117,8 @@ final class PersistentCollection extends \Doctrine\Common\Collections\Collection
|
||||
*/
|
||||
private $_isDirty = false;
|
||||
|
||||
private $_isSerializing = false;
|
||||
|
||||
/**
|
||||
* Creates a new persistent collection.
|
||||
*/
|
||||
@ -427,4 +429,18 @@ final class PersistentCollection extends \Doctrine\Common\Collections\Collection
|
||||
{
|
||||
$this->_isDirty = $dirty;
|
||||
}
|
||||
|
||||
/* Serializable implementation */
|
||||
|
||||
/**
|
||||
* Called by PHP when this collection is serialized. Ensures that only the
|
||||
* elements are properly serialized.
|
||||
*
|
||||
* @internal Tried to implement Serializable first but that did not work well
|
||||
* with circular references. This solution seems simpler and works well.
|
||||
*/
|
||||
public function __sleep()
|
||||
{
|
||||
return array('_elements');
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user