the class Doctrine\ORM\Event\LifecycleEventArgs have method getEntity() for see get Entity->getId(); what object id was modified.
I use the method public function onFlush(OnFlushEventArgs $eventArgs) . How can see the ID of the object that has been inserted?
foreach ($uow->getScheduledEntityInsertions() AS $entity) {
if (!$entity instanceof Modificacion) {
$modificacion = new Modificacion();
$modificacion->setFechamod(new \DateTime('now'));
$className = join('', array_slice(explode('\\', get_class($entity)), -1));
$modificacion->setEntidad($className);
$modificacion->setIdentificador($eventArgs->getEntity()->getId());//not working
$modificacion->setTipo('Inserción');
$securityContext = $this->container->get('security.context');
$modificacion->setEmpleado($securityContext->getToken()->getUser());
$modificacion->setInfo('');
$em->persist($modificacion);
$classMetadata = $em->getClassMetadata(get_class($modificacion));
$uow->computeChangeSet($classMetadata, $modificacion);
}
}
thanks in advance.