我一直在寻找几个小时,我真的不明白为什么!我已经阅读了很多SO帖子(this for example),但找不到问题所在。
我想handle File Uploads with Doctrine使用lifecycleCallbacks
,我的问题是callbacks
方法永远不会被解雇?
我的实体:
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* Etablissement
*
* @ORM\Table(name="etablissement")
* @ORM\Entity
* @ORM\HasLifecycleCallbacks
*/
class Etablissement
{
/**
* @ORM\PrePersist()
* @ORM\PreUpdate()
*/
public function firstMethod()
{
exit('inside first method');
}
/**
* @ORM\PostPersist()
* @ORM\PostUpdate()
*/
public function secondMethod()
{
exit('inside secondMethod method');
}
// ...
坚持代码:
$entity = new Etablissement();
$form = $this->createCreateForm($entity);
$form->handleRequest($request);
if ($form->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->persist($entity);
$em->flush();
// ...........
这使实体在数据库中保持良好状态,而不是exited
!请帮忙!