简体   繁体   English

给定的模型已经开始“ default_workflow”过程

[英]The given model has already started the “default_workflow” process

I am building an entity listener in an application based on symfony 2.7. 我正在基于symfony 2.7的应用程序中构建实体侦听器。 It will apply a tag to a video whenever the video's owning group changes. 每当视频拥有者组更改时,它将在视频上应用标签。

My listener looks like this so far: 到目前为止,我的听众看起来像这样:

public function preUpdate($video, $args)
{
    $changeSet = $args->getEntityChangeSet();
    if(!array_key_exists('ownerGroup', $changeSet )){
        return;
    }

    $oldGroupObj = $changeSet['ownerGroup'][0];
    $oldGroupName = $oldGroupObj->getName();

    //die($oldGroupName); //Gives us a valid group name string.

    $tagRepository = $args->getEntityManager()->getRepository('AppBundle:Tag');
    $tag = $tagRepository->findOneBy( ['title' => 'migrated' . $oldGroupName] );
    if( $tag === null ){
        $tag = new Tag;
        $tag->setTitle('migrated' . $oldGroupName);
    }

    $video->addTag($tag); 

}

The problem is that last line. 问题是最后一行。 When I run it, it causes this exception: 当我运行它时,它将导致以下异常:

The given model has already started the "default_workflow" process. 给定的模型已经开始“ default_workflow”过程。

What does this exception mean, and how can I save the new tag to my video when the owning group changes? 此例外是什么意思?当拥有者组更改时,如何将新标签保存到视频中?

Trully , I have not develop application with symfony. 确实 ,我还没有使用symfony开发应用程序。 But after read some documentation symfony, for your case exception The given model has already started the "default_workflow" process, interested at " Process Component ", focused at Running Function (mustRun()), except that it will throw a ProcessFailedException if the process couldn't be executed successfully. 但是在阅读了一些文档symfony之后,针对您的案例异常给定的模型已经启动了“ default_workflow”进程,该进程对“ Process Component ”感兴趣,关注的是Running Function (mustRun()),不同之处在于,如果该进程将抛出ProcessFailedException无法成功执行。 So, Globally , do not just focussed at your "function preUpdate", but all-of-your-big-code-symfony, because that exception "open from" The Process-Of-Your-Application 因此, 在全球范围内 ,不仅要关注您的“功能preUpdate”,还要关注您的所有大代码符号,因为该异常是“从您的应用程序的流程中打开的”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM