symfony - Get new value of entity field after Doctrine flush -
i'm trying resize image after persisting entity doctrine. in entity code, i'm setting field specific value before flush , update :
/** * @orm\prepersist() * @orm\preupdate() */ public function preupload() { if (null !== $this->getfile()) { // whatever want generate unique name $filename = sha1(uniqid(mt_rand(), true)); $this->image = $filename.'.png'; } }
so image field supposed updated. in controller, i'd resize job:
if ($form->isvalid()) { $em->persist($activite); $em->flush(); //resize image $img_path = $activite->getimage(); resizeimage($img_path); }
however, @ point in code, value of $activite->image still null. how can new value?
(everything saved in database.)
the entitymanager
has refresh()
method update entity latest values database.
$em->refresh($entity);
Comments
Post a Comment