public function processChanges(array $data = array())
{
foreach ($data as $property => $value) {
if ($property === '_id') {
continue;
}
if (!array_key_exists($property, $this->_cleanData)) {
$this->addOperation('$set', $property, $value);
continue;
}
$newValue = $value;
$oldValue = $this->_cleanData[$property];
if (MongoDBRef::isRef($newValue) && MongoDBRef::isRef($oldValue)) {
$newValue['$id'] = $newValue['$id']->__toString();
$oldValue['$id'] = $oldValue['$id']->__toString();
}
if ($newValue !== $oldValue) {
$this->addOperation('$set', $property, $value);
}
}
foreach ($this->_cleanData as $property => $value) {
if (array_key_exists($property, $data)) {
continue;
}
$this->addOperation('$unset', $property, 1);
}
}