Symfony2 DoctrineExtensions preSoftDelete event ca

2019-07-03 05:57发布

I've got a problem implementing the preSoftDelete Event from the L3pp4ard DoctrineExtensions Bundle for Symfony2. The softDelete function is working just fine, but I want to add an deletedBy (userid) next to the deletedAt (datetime). To do that, I want to listen to the event that is called (preSoftDelete), but I can't get it to work. `

The file that (should) calls the event can be found at github. I have confirmed that this script runs.

I have already added a service in my config.yml:

utwente.idbbundle.presoftdelete:
  class: Utwente\IdbBundle\EventListener\UtwenteIdbSoftDeleteListener
  tags: 
    - { name: gedmo.listener.softdeleteable, event: preSoftDelete, method: onPreSoftDelete }

and I have made the class/method that should do something. For now it echo's hello, and stops the script execution (for testing).

<?php    
namespace Utwente\IdbBundle\EventListener;

class UtwenteIdbSoftDeleteListener {
  public function onPreSoftDelete(LifecycleEventArgs $args){
    echo "Hoi";
    die();
  }
}
?>

But it doesn't work. Any ideas?

(It does work when I use name: kernel.event_listener, event: kernel.request, and leave LifecycleEventArgs $args out).

1条回答
【Aperson】
2楼-- · 2019-07-03 06:30

using

tags: 
      - { name: doctrine.event_listener, event: preSoftDelete, connection: default }

was the answer...

查看更多
登录 后发表回答