1
0
mirror of synced 2025-01-20 07:21:40 +03:00

[2.0] Ensuring that PersistentCollection instances that are injected by Doctrine can be transparently serialized.

This commit is contained in:
romanb 2009-05-07 17:56:09 +00:00
parent cfae81e11a
commit 0a81ae773d

View File

@ -117,6 +117,8 @@ final class PersistentCollection extends \Doctrine\Common\Collections\Collection
*/ */
private $_isDirty = false; private $_isDirty = false;
private $_isSerializing = false;
/** /**
* Creates a new persistent collection. * Creates a new persistent collection.
*/ */
@ -427,4 +429,18 @@ final class PersistentCollection extends \Doctrine\Common\Collections\Collection
{ {
$this->_isDirty = $dirty; $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');
}
} }