I'm using Oneup\AclBundle and after last update I can't save any entity no more.
When I try to save my entity to the Database:
$em = $this->getDoctrine()->getManager();
$em->persist($entity);
$em->flush();
... I get this error:
ContextErrorException: Catchable Fatal Error: Argument 1 passed to Oneup\AclBundle\EventListener\DoctrineSubscriber::postPersist() must be an instance of Doctrine\Common\Persistence\Event\LifecycleEventArgs, instance of Doctrine\ORM\Event\LifecycleEventArgs given, called in vendor/symfony/symfony/src/Symfony/Bridge/Doctrine/ContainerAwareEventManager.php on line 61 and defined in vendor/oneup/acl-bundle/Oneup/AclBundle/EventListener/DoctrineSubscriber.php line 18
I found this change for Oneup/AclBundle:
https://github.com/danez/OneupAclBundle/commit/f3eacf040677019caad73d221a610c73cbd7dd25
Based on this, I tried to change the file vendor/oneup/acl-bundle/Oneup/AclBundle/EventListener/DoctrineSubscriber.php:
use Doctrine\Common\Persistence\Event\LifecycleEventArgs;
...
class DoctrineSubscriber implements EventSubscriber
{
...
public function postPersist(LifecycleEventArgs $args)
{
...
$entity = $args->getObject();
$object = new \ReflectionClass($entity);
...
}
}
... to:
use Doctrine\ORM\Event\LifecycleEventArgs;
...
class DoctrineSubscriber implements EventSubscriber
{
...
public function postPersist(LifecycleEventArgs $args)
{
...
$entity = method_exists($args, 'getObject')? $args->getObject(): $args->getEntity(); // the called method sometimes changes
$object = new \ReflectionClass($entity);
...
}
}
... and like this it works.
How can I manage to get things working again with this update?
I guess I must somehow make a common doctrine EventClass gets fired, not a ORM doctrine EventClass.
Upon update the log for this bundle was:
- Updating oneup/acl-bundle dev-master (b3c6ddb => fc3fdbc)
Checking out fc3fdbcf3547f0e0520ebb7f7f7e86e3a05779d4