I'm currently looking at expanding the advancedworkflow to support timed transition. For example notifying content reviewers that they should have a look at something. I'm dumping a couple of ideas on how to support this. I'm keen on getting @nyeholt and @sminnee ideas on this.
Allow multiple workflows for a WorkflowApplicable extended objects
This allows us to configure multiple workflows per objects. Another approach would to use some sort of hierarchial state machine pattern or a state machine with decision trees, but I think that would complicate this a lot more.
An example would be to have:
- A workflow that updates the state based on user actions in the CMS.
- A workflow that updates the state based on time.
- And another one that updates the state from external influences, i.e. web services.
This refactoring includes changing the WorkflowApplicable
from
public static $has_one = array(
'WorkflowDefinition' => 'WorkflowDefinition',
);
to
public static $has_many = array(
'WorkflowDefinitions' => 'WorkflowDefinition',
);
.. and change all the relevant UI elements to support that.
Create Transitions that are triggered via timers
Waiting for review - initial state
- transition to State.Notificated (timestamped)
Notificated
- on entry: send email to content owner
- on entry: send email to administrators group
- transition to State.Renotificated (x days later)
- transition to State.Published
Overdue
- on entry: send email to content owner
- on entry: send email to administrators group
- transition to State.Renotificated (x days later)
- transition to State.Published
This will require transitions to be able to save triggerstamps persistance so it can be queried and exectuted. Most likely with the help of the queuedjobs
module.
How about creating a WorkflowTimeTransition
?
Other refactoring ideas
Break out Create state from WorkFlowAction
The current state should should reflect which state the current Workflow is in.
A State can have:
- getEntryActions
- getActions (that are run every time the workflow is queried for updates)
- getExitActions
It changes the perception from actions to state:
Example:
Waiting for approval - Initial state
- on entry: send notification email to Publisher (action)
-> transition to State.Approved
-> transition to State.Rejected
Approved
- on entry: send notification email to Author (action)
- transition to State.Published
Rejected
- on entry: send notification email to Author (action)
- transition to State.Waiting for approval
- transition to State.Abort
Published
- on entry: Publish article (action)
- on entry: close workflow (action)
Abort
- On entry: send email to Author and Publisher (action)
This makes states a bit more lightweight and are basically just placeholders for actions.
Allow Transitions to have actions
Good for sending notifications or scheduling embargos / offline tasks
This separates states from actions and makes actions more generic and it's easier to visualize the workflow.