【发布时间】: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