Commit 0a81ae77 authored by romanb's avatar romanb

[2.0] Ensuring that PersistentCollection instances that are injected by...

[2.0] Ensuring that PersistentCollection instances that are injected by Doctrine can be transparently serialized.
parent cfae81e1
......@@ -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');
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment