【问题标题】:Unable to find a workflow for class "FooBundle\Entity\Document" when that class have two workflows当“FooBundle\Entity\Document”类有两个工作流时,找不到该类的工作流
【发布时间】:2019-02-12 15:03:12
【问题描述】:

异常错误表示找不到存在的类并且在项目中使用。这里是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] request.CRITICAL:未捕获的 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');
}

【问题讨论】:

  • 可能是您的namespace 不正确?
  • 不,@ImanaliMamadiev。通过一个工作流程,它可以工作。有两个工作流$workflows->get($document) 需要工作流名称。修复出现此错误的名称。

标签: symfony symfony4 symfony-workflows


【解决方案1】:

在你的树枝上写:

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

代替:

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

【讨论】:

    猜你喜欢
    • 2021-12-02
    • 1970-01-01
    • 2022-12-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多