始终调用Symfony条令事件预更新
我不明白为什么在我显示实体时总是调用事件预更新: 抽象类Fiche:始终调用Symfony条令事件预更新,symfony,events,doctrine,Symfony,Events,Doctrine,我不明白为什么在我显示实体时总是调用事件预更新: 抽象类Fiche: /** * Fiche * * @ORM\Table(name="fiches") * @ORM\Entity(repositoryClass="FichesBundle\Repository\FicheRepository") * @ORM\InheritanceType("JOINED") * @ORM\MappedSuperclass * @ORM\HasLifecycleCallbacks() */ a
/**
* Fiche
*
* @ORM\Table(name="fiches")
* @ORM\Entity(repositoryClass="FichesBundle\Repository\FicheRepository")
* @ORM\InheritanceType("JOINED")
* @ORM\MappedSuperclass
* @ORM\HasLifecycleCallbacks()
*/
abstract class Fiche
{
/**
* @var \DateTime
*
* @ORM\Column(name="dateLastUpdate", type="datetimetz", nullable=true)
*/
private $dateLastUpdate;
/**
* @ORM\PreUpdate
*/
public function updateDateLastUpdate()
{
$this->setDateLastUpdate(new \Datetime());
}
[...]
}
第五类干预:
/**
* FicheIntervention
*
* @ORM\Table(name="fiches_intervention")
* @ORM\Entity(repositoryClass="FichesBundle\Repository\FicheInterventionRepository")
*/
class FicheIntervention extends Fiche
{
[...]
}
行动方法:
/**
* @param \FichesBundle\Entity\FicheIntervention $ficheIntervention
* @return array
*
* @Route("/{id_ficheIntervention}", name="route_fiches_ficheIntervention")
* @ParamConverter("ficheIntervention", options={"mapping" : {"id_ficheIntervention" : "id"}})
* @Template()
*/
public function FicheInterventionAction(\FichesBundle\Entity\FicheIntervention $ficheIntervention)
{
return array(
"ficheIntervention" => $ficheIntervention
);
}
每次我调用操作时,日期都是更新的。为什么?
您能帮我吗,plz。在我看来,您每次执行操作时都在创建实体类的实例。您是否尝试使用存储库取回对象?我想当我使用$this->getDoctrine()->getEntityManager()->getRepository(…)->findOneById($id)时,您需要更多地展示相同的问题;在我看来,每次执行操作时都在创建实体类的实例。您是否尝试使用存储库取回对象?我想当我使用$this->getDoctrine()->getEntityManager()->getRepository(…)->findOneById($id)时,您需要更多地展示相同的问题;