/**
*
* @param string $identifier The object's identifier
* @param object $object The object to work on
* @param array $properties The properties to collect (as per class schema)
* @param boolean $dirty A dirty flag that is passed by reference and set to TRUE if a dirty property was found
* @return array
*/
protected function collectProperties($identifier, $object, array $properties, &$dirty)
{
$propertyData = [];
foreach ($properties as $propertyName => $propertyMetaData) {
$propertyValue = $this->checkPropertyValue($object, $propertyName, $propertyMetaData);
// handle all objects now, because even clean ones need to be traversed
// as dirty checking is not recursive
if ($propertyValue instanceof PersistenceMagicInterface) {
if ($this->persistenceSession->isDirty($object, $propertyName)) {
$dirty = true;
$this->flattenValue($identifier, $object, $propertyName, $propertyMetaData, $propertyData);
} else {
$this->persistObject($propertyValue, $identifier);
}
} elseif ($this->persistenceSession->isDirty($object, $propertyName)) {
$dirty = true;
$this->flattenValue($identifier, $object, $propertyName, $propertyMetaData, $propertyData);
}
}
return $propertyData;
}