The given object must contain the Persistence_Object_Identifier property, thus
the PersistenceMagicInterface type hint. A "new" object does not necessarily
have to be known by any repository or be persisted in the end.
Objects registered with this method must be known to the getObjectByIdentifier()
method.
public registerNewObject ( Aspect\PersistenceMagicInterface $object ) : void | ||
$object | Aspect\PersistenceMagicInterface | The new object to register |
return | void |
/** * After returning advice, making sure we have an UUID for each and every entity. * * @param JoinPointInterface $joinPoint The current join point * @return void * @Flow\Before("Neos\Flow\Persistence\Aspect\PersistenceMagicAspect->isEntity && method(.*->(__construct|__clone)()) && filter(Neos\Flow\Persistence\Doctrine\Mapping\Driver\FlowAnnotationDriver)") */ public function generateUuid(JoinPointInterface $joinPoint) { /** @var $proxy PersistenceMagicInterface */ $proxy = $joinPoint->getProxy(); ObjectAccess::setProperty($proxy, 'Persistence_Object_Identifier', Algorithms::generateUUID(), true); $this->persistenceManager->registerNewObject($proxy); }