raoul2000 / yii2-workflow

A simple workflow engine for Yii2

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Change state by timeout

timz opened this issue · comments

Hello! How to change state by this rule: If the Post is not published after 10 days after save, then assign the status of "archive" ?

commented

Hello @timz,
yii2-workflow doesn't provide a way to automatically perform a transition the way you're describing : on save the transition to the target status is applied. It can end in success or in error, but the target status once defined outside of yii2-workflow cannot be changed by yii2-workflow. Basically, yii2-workflow doesn't implement conditional transition branching.

So you will have to test the "Archive" condition before saving the Model, and if true, set its status to "Archive".

ciao
😎

More ideally you would use a cron job for this to run once a day executing a script that would query the Post table for posts with a date that is more than 10 days old and update its status to be archived.

commented

yes, that's what I would suggest ... muuuch more simple 😉