Symfony 4.工作流程initial_place不起作用

时间:2019-02-11 10:16:51

标签: workflow symfony4

在workflow.yml中,我定义了initial_place。

framework:
    workflows:
        case_workflow:
            type: 'workflow' # or 'state_machine'
            audit_trail:
                enabled: true
            marking_store:
                type: 'multiple_state' # or 'single_state'
                arguments:
                    - 'currentPlace'
            supports:
                - App\Entity\Cases\CoreCase

            initial_place: initial

            places:
                - initial
                - review
                - rejected
                - published

            transitions:
                to_review:
                    from: initial
                    to:   review
                publish:
                    from: review
                    to:   published
                reject:
                    from: review
                    to:   rejected

在实体中我定义了属性

/**
 * @ORM\Column(type="string", length=50)
 */
private $currentPlace;

在控制器中,我创建实体并将其持久化

$dieselCase = new DieselCase();
$dieselCase->setUser($account);
$dieselCase->setCustomer($account);
$em->persist($dieselCase);
$em->flush();

但是currentPlace未被设置为initial。它是工作流捆绑包中的错误吗?我该如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

答案很晚,但是,这是Symfony的工作方式null == initial_place

如果在数据库为WorkflowInterface时使用getMarking($dieselCase)null,它将报告您配置的位置为['initial']。或者,如果您使用marking_store: type: 'single_state',它将报告'initial'

仅当您执行$workflow->apply($dieselCase, 'to_review')

时,才会填充“ currentPlace”标记存储