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

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -