raoul2000 / yii2-workflow

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

cebe lifecycle behaviour? #1

Closed philippfrenzel closed 9 years ago

philippfrenzel commented 9 years ago

Did you see this yii2 extension, maybe you can use some of the behaviour on your side too and attach the events?

Cheers Philipp

raoul2000 commented 9 years ago

I did not see this one... thanks to point it out.

From what I can see, this behavior checks that transition are valid. Yii2-workflow does the same, and also works on validation, so I'm not sure what I could reuse... I will take a close look

ciao

philippfrenzel commented 9 years ago

Thanks, i thought if it brings benefits, I should mention it;)

raoul2000 commented 9 years ago

well I had a second llok and finally I have implemented yesterday support for the workflow definition provided as a structured array with same format than the one @cebe uses for the lifecycle behavior.

It's minimal but can be intresting if you don't need anything but statuses and transitions.

example :

[
  'draft' => ['published', 'ready'],
  'ready' => ['published','archived'],
  'published' => ['draft', 'archived'],
  'archived' => []
]

So you see that it did brings benefits :smile:

philippfrenzel commented 9 years ago

:+1: I like the definition syntax! Actually looking at your docs, I don't really get, how you assign the PostWorkflow to the Post Model?

raoul2000 commented 9 years ago

This is based on naming convention : by convention the model Post will be associated to the workflow called PostWorkflow. Then, there must be a class named PostWorkflow that implements the IWorkflowDefinitionProvider interface.

Where to store the PostWorkflow class ? By default, it is supposed to be stored in @app/models.

Of course you can change all these default setting by providing the appropriate configuration settings to the workflow Source component that is used by the SimpleworkflowBehavior to access workflow items.

Check this page for a first draft on workflow creation.

I will write something more in detail in the guide soon ....