我使用Symfony的2.3奏鸣曲管理员捆绑与DoctrineExtensions (由启用StofDoctrineExtensionsBundle )。 我启用,配置和测试成功SoftDeleteable和Timestampable组件。
现在,当我尝试使用Symfony的服务标记添加另一种学说事件订阅,它似乎在softdeleteable监听器被禁用。
我的服务:
my.contact.listener.tag:
class: My\ContactBundle\EventListener\TagListener
tags:
- { name: doctrine.event_subscriber, connection: default }
calls:
- [ setTagManager, [ @fpn_tag.tag_manager ] ]
订户:
namespace My\ContactBundle\EventListener;
use Doctrine\Common\EventSubscriber;
use Doctrine\ORM\Event\LifecycleEventArgs;
use DoctrineExtensions\Taggable\Taggable;
use FPN\TagBundle\Entity\TagManager;
class TagListener implements EventSubscriber
{
/**
* @var TagManager
*/
private $tagManager;
/**
* @param \FPN\TagBundle\Entity\TagManager $tagManager
*/
public function setTagManager($tagManager)
{
$this->tagManager = $tagManager;
}
/**
* Load tags for Taggable entities
*
* @param LifecycleEventArgs $args
*/
public function postLoad(LifecycleEventArgs $args)
{
$entity = $args->getEntity();
if ($entity instanceof Taggable) {
$this->tagManager->loadTagging($entity);
}
}
/**
* Save tags for Taggable entities
*
* @param LifecycleEventArgs $args
*/
public function preUpdate(LifecycleEventArgs $args)
{
$entity = $args->getEntity();
if ($entity instanceof Taggable) {
$this->tagManager->saveTagging($entity);
}
}
/**
* Save tags for Taggable entities
*
* @param LifecycleEventArgs $args
*/
public function prePersist(LifecycleEventArgs $args)
{
$entity = $args->getEntity();
if ($entity instanceof Taggable) {
$this->tagManager->saveTagging($entity);
}
}
public function getSubscribedEvents()
{
return array(
'prePersist',
'preUpdate',
'postLoad',
);
}
}
在每一个请求,我得到异常:
Listener "SoftDeleteableListener" was not added to the EventManager!
如果我禁用我的用户,问题就消失了。 如何让我的事件订阅者,并有softdeleteable呢?