protected function onSuccess(ParticipateTrip $participateTrip) { $participateTrip->setDateInscription(new \DateTime()); $operation = new Operation(); $operation->setDate(new \DateTime()); $operation->setDescription("New payment for the trip : " . $participateTrip->getTrip()->getName()); $operation->setLibelle("Payment for a trip"); $operation->setMontant($participateTrip->getTrip()->getPrice()); $montant = $this->em->getRepository('ESNTreasuryBundle:Caisse')->getLastCaisse(); $caisse = new Caisse(); $caisse->setMontant($montant + $operation->getMontant()); $this->em->persist($caisse); $this->em->persist($operation); $this->em->persist($participateTrip); $this->em->flush(); }