1
我收到以下錯誤消息,Symfony2的postUpdate監聽器不工作
Catchable fatal error: Argument 3 passed to Doctrine\ORM\Event\PreUpdateEventArgs::__construct() must be of the type array, null given, called in
,不知道在哪裏解決這個開始。你可以看到我的聽衆(縮短)低於
public function postUpdate(LifecycleEventArgs $args){
$entity = $args->getEntity();
$em = $args->getEntityManager();
$args->getEntityManager()->clear();
$securityContext = $this->container->get('security.context');
$token = $securityContext->getToken();
$userLoggedIn = $token->getUser();
if ($entity instanceof Activity) {
$em->flush();
}
}
有沒有人有任何建議?
下面是從配置
activity.listener:
class: My\Bundle\EventListener\ActivityListener
arguments: ['@service_container']
tags:
- { name: doctrine.event_listener, event: prePersist }
- { name: doctrine.event_listener, event: postPersist }
- { name: doctrine.event_listener, event: postUpdate }
您可以粘貼與此偵聽器相關的服務定義嗎? –
我很好奇當你試圖實現'PostUpdate'事件時爲什麼提到'PreUpdateEventArgs'類。 –
我已經添加了上面的服務定義 –