当类“ FooBundle \ Entity \ Document”具有两个工作流时,无法找到该工作流

时间:2018-09-07 09:26:24

标签: symfony symfony4 symfony-workflows

异常错误表明找不到一个存在的类,该类已在项目中使用。这是WF配置:

工作流程配置:

first_workflow_name:
    type: 'workflow'
    supports:
        - FooBundle\Entity\Document
    marking_store:
        type: 'multiple_state'
        arguments:
            - 'currentState'

second_workflow_name:
    type: 'workflow'
    supports:
        - FooBundle\Entity\Document
    marking_store:
        type: 'multiple_state'
        arguments:
            - 'currentState'

,这里是记录的异常:

记录的异常:

  

[2018-09-07 09:11:38]请求。关键:未捕获的PHP异常   Symfony \ Component \ Workflow \ Exception \ InvalidArgumentException:“无法   查找类“ FooBundle \ Entity \ Document”的工作流程。”

控制器

public function getFooAction(
    $id,
    Registry $workflows
) {
    $document = $this->getDoctrine()
        ->getRepository('FooBundle:Document')
        ->findOneBy(['id' => $id]);

    if (!$document) {
        throw $this->createNotFoundException(
            'No Document found for id '.$id
        );
    }

    $w = $workflows->get($document, 'second_workflow_name');
}

1 个答案:

答案 0 :(得分:0)

在树枝上写:

workflow_can(you_variable,'second_workflow_name','arguments')

代替:

workflow_can(you_variable,'arguments','second_workflow_name')