致电帖子删除不起作用

时间:2018-08-16 07:31:42

标签: symfony doctrine-orm symfony-3.4 symfony-eventdispatcher

我的项目有问题:

Not called :

public function postRemove(LifecycleEventArgs $event)
{
    $test = 1;
    $test1 = 2;
}

Called :

public function preRemove(LifecycleEventArgs $event)
{
    $test = 1;
    $test1 = 2;
}

奇怪的是没有调用postRemove。我确认该实体已从数据库中删除。请给个主意。

1 个答案:

答案 0 :(得分:0)

public function getSubscribedEvents()
{
    return array(
        'postPersist',
        'postUpdate',
        'postRemove' // !!! 
    );
}

public function postUpdate(LifecycleEventArgs $args)
{
    dump('Update');
}

public function postPersist(LifecycleEventArgs $args)
{
    dump('Persist');
}


public function postRemove(LifecycleEventArgs $args)
{
    dump('Remove');
}