I'm getting the following error message,
Catchable fatal error: Argument 3 passed to Doctrine\ORM\Event\PreUpdateEventArgs::__construct() must be of the type array, null given, called in
and don't know where to start in solving this. You can see my listener (shortened) below
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();
}
}
Has anyone got any suggestions?
Here's my services section from config
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 }
The problem is caused probably by the
$em->flush()
inside the postUpdate event handler which later will trigger theUnitOfWork::executeUpdates
function call.If that's the case then the only workaround I've found is the one I documented in a Doctrine bug report (although I don't regard this as a true Doctrine bug).