public function computeChangeSets()
{
$this->computeScheduleInsertsChangeSets();
$this->computeScheduleUpsertsChangeSets();
// Compute changes for other MANAGED documents. Change tracking policies take effect here.
foreach ($this->identityMap as $className => $documents) {
$class = $this->dm->getClassMetadata($className);
if ($class->isEmbeddedDocument) {
/* we do not want to compute changes to embedded documents up front
* in case embedded document was replaced and its changeset
* would corrupt data. Embedded documents' change set will
* be calculated by reachability from owning document.
*/
continue;
}
// If change tracking is explicit or happens through notification, then only compute
// changes on document of that type that are explicitly marked for synchronization.
switch (true) {
case $class->isChangeTrackingDeferredImplicit():
$documentsToProcess = $documents;
break;
case isset($this->scheduledForDirtyCheck[$className]):
$documentsToProcess = $this->scheduledForDirtyCheck[$className];
break;
default:
$documentsToProcess = array();
}
foreach ($documentsToProcess as $document) {
// Ignore uninitialized proxy objects
if ($document instanceof Proxy && !$document->__isInitialized__) {
continue;
}
// Only MANAGED documents that are NOT SCHEDULED FOR INSERTION, UPSERT OR DELETION are processed here.
$oid = spl_object_hash($document);
if (!isset($this->documentInsertions[$oid]) && !isset($this->documentUpserts[$oid]) && !isset($this->documentDeletions[$oid]) && isset($this->documentStates[$oid])) {
$this->computeChangeSet($class, $document);
}
}
}
}