Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/symfony/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
始终调用Symfony条令事件预更新_Symfony_Events_Doctrine - Fatal编程技术网

始终调用Symfony条令事件预更新

始终调用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:

/**
 * 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)时,您需要更多地展示相同的问题;