raoul2000 / yii2-workflow

A simple workflow engine for Yii2
BSD 3-Clause "New" or "Revised" License
171 stars 48 forks source link

Event on enter workflow #66

Closed ferllings closed 3 years ago

ferllings commented 3 years ago

Hello,

I use SimpleWorkflowBehavior::EVENT_AFTER_CHANGE_STATUS To trigger an action when my workflow status changes.

But this event is not triggered when my model enters the workflow using

$model->enterWorkflow();

Is there an event that I can use,like afterEnterWorkflow{MyWorkflow}

Thanks

raoul2000 commented 3 years ago

Hi @ferllings , there is indeed an event fired when a model enter a workflow. The Event Model implemented by yii2-workflow is described here. You'll find events like :

Above events are fired when a model enters a workflow and so you could attach a handler to the ones that best fit your needs. Cheers

ferllings commented 3 years ago

Thanks, It's working.

And it looks like I was wrong: SimpleWorkflowBehavior::EVENT_AFTER_CHANGE_STATUS is also executed if you enter the workflow.