/**
* After returning advice, generates the value hash for the object
*
* @param JoinPointInterface $joinPoint The current join point
* @return void
* @Flow\After("Neos\Flow\Persistence\Aspect\PersistenceMagicAspect->isNonEmbeddedValueObject && method(.*->__construct()) && filter(Neos\Flow\Persistence\Doctrine\Mapping\Driver\FlowAnnotationDriver)")
*/
public function generateValueHash(JoinPointInterface $joinPoint)
{
$proxy = $joinPoint->getProxy();
$proxyClassName = get_class($proxy);
$hashSourceParts = [];
$classSchema = $this->reflectionService->getClassSchema($proxyClassName);
foreach ($classSchema->getProperties() as $property => $propertySchema) {
// Currently, private properties are transient. Should this behaviour change, they need to be included
// in the value hash generation
if ($classSchema->isPropertyTransient($property) || $this->reflectionService->isPropertyPrivate($proxyClassName, $property)) {
continue;
}
$propertyValue = ObjectAccess::getProperty($proxy, $property, true);
if (is_object($propertyValue) === true) {
// The persistence manager will return NULL if the given object is unknown to persistence
$propertyValue = $this->persistenceManager->getIdentifierByObject($propertyValue) ?: $propertyValue;
}
$hashSourceParts[$property] = $propertyValue;
}
ksort($hashSourceParts);
$hashSourceParts['__class_name__'] = $proxyClassName;
$serializedSource = $this->useIgBinary === true ? igbinary_serialize($hashSourceParts) : serialize($hashSourceParts);
$proxy = $joinPoint->getProxy();
ObjectAccess::setProperty($proxy, 'Persistence_Object_Identifier', sha1($serializedSource), true);
}