gpt4 book ai didi

symfony - Doctrine postPersist 事件已弃用 getEntity 函数

转载 作者:行者123 更新时间:2023-12-01 13:10:05 26 4
gpt4 key购买 nike

在 Symfony 中创建 Doctrine postPersist EventListener 后,我的 IDE 指向 $args->getEntity() 行;由于已被弃用,我不知道如何解决这个问题,因为它与 Symfony docs for version 2.8 中的代码相同。

IDE PhpStorm 的屏幕截图:https://image.prntscr.com/image/tT4zAlXkQMOxqvo6TLblUg.png

代码:

public function postPersist(LifecycleEventArgs $args)
{
$entity = $args->getEntity();

// ...
}

最佳答案

在你使用的 eventlistener 类中,我猜你设置了错误的类。

use Doctrine\Common\Persistence\Event\LifecycleEventArgs; -> the getEntity() method is deprecated.

你应该使用:

use Doctrine\ORM\Event\LifecycleEventArgs;

关于symfony - Doctrine postPersist 事件已弃用 getEntity 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45856933/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com