简体   繁体   中英

The given model has already started the “default_workflow” process

I am building an entity listener in an application based on 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.

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. 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. 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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