php - Symfony2 and Doctrine - @ORM\PostPersist() does not work -
i have file upload function on symfony2 project. used http://symfony.com/doc/current/cookbook/doctrine/file_uploads.html example.
the problem @orm\postpersist() not trigered , file not stored in specific folder.
here have:
1 entity "manuscript" manage file:
/** * @orm\postpersist() * @orm\postupdate() */ public function upload() { if (null === $this->file) { return; } $this->file->move( $this->getuploadrootdir().date('ymdhis').'_'.$this->file->getclientoriginalname() ); }
i tryed put var_dump() there var_dump() never actioned, never entering there.
in form, have file:
public function buildform(formbuilderinterface $builder, array $options) { $builder->add('file', 'file', array('label'=> 'htm file', 'required' => true)); }
finally, in controller, have
if ($request->ismethod('post')) { $form->bind($request); if ($form->isvalid()) { $em_scipub->persist($enquiry); $em_scipub->flush(); ....
i fixed issue, think forgot add @orm\haslifecyclecallbacks
so, in manuscript entity, should that:
/** * manuscripts * * @orm\table(name="manuscripts") * @orm\entity * @orm\haslifecyclecallbacks * */ class manuscript { ....
Comments
Post a Comment