Symfony2 DoctrineExtensions preSoftDelete事件调用 [英] Symfony2 DoctrineExtensions preSoftDelete event call
问题描述
我在Symfony2的L3pp4ard DoctrineExtensions Bundle中实现了preSoftDelete Event的问题。 softDelete功能正常工作,但是我想在deletedAt(datetime)旁边添加一个deletedBy(userid)。为了做到这一点,我想听听被称为(preSoftDelete)的事件,但是我不能让它工作。 `
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. `
可以在 github 。我已经确认这个脚本运行。
The file that (should) calls the event can be found at github. I have confirmed that this script runs.
我已经在我的config.yml中添加了一个服务:
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?
(当我使用名称时,它的工作正常:kernel.event_listener,event:kernel.request
并将 LifecycleEventArgs $ args
out)。
(It does work when I use name: kernel.event_listener, event: kernel.request
, and leave LifecycleEventArgs $args
out).
推荐答案
使用
tags:
- { name: doctrine.event_listener, event: preSoftDelete, connection: default }
是答案...
这篇关于Symfony2 DoctrineExtensions preSoftDelete事件调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!