Hi Salsero,
oups ... I'm using PHP 5.3 and the domxml extension was installed on my dev platform, so I used it. Maybe that's no the better choice. What is your advice ? What php extension should I use to parse and xpath XML ?

Unfortunatly, right now, there's not much you can do about it, apart installing domxml. Then depending on my free time, I can rewrite the yEd with a more familiar parser extension.

Hi Salsero,
deal then : I will remove the extension_loaded test ! (anyway I currently have no time to rewrite the code with another parser )

Now regarding your question on how to handle events with simpleWorkflow, here is what you should do :

first of all, your model must extends from SWActiveRecord instead of CActiveRecord (or whateever base class your model may extend). If you take a look at the SWActiveRecord source code, you'll see that this class declares all events that come with simpleWorkflow

then it's time for you to write some code in order to handle simpleWorkflow events. To do so, you have 2 options

directly add the event handler method in your model class. For instance, if you want your model to handle the enterWorkflow event, create a method with the following signature : enterWorkflow($event)
..or...

you may also want to group all your event handlers into a CActiveRecord behavior. In this case, create a new class that extends SWActiveRecordBehavior and implement the handlers for the events you're intrested in. Here is an example of such behavior class (from the unit test classes). Of course, once done, you just have to attache your new behavior to your model, instead of attaching the default SWActiveRecordBehavior class.

At last, please note that all event raised by the simpleWorkflow extension are SWEvent objects. They give you access to both the source and destination status (and to the sender instance, of course).

That's it ! ... if you encounter any problem (yes yes, that's possible ) do not hesitate to ask and be sure that I'll do my best to help.
ciao

hi Salsero,
let's say you have defined a transition between workflowA/status1 to workflowB/status2, and you want to validate that when the AR performs this transition, its 'category' attribute is 'required'.

As you can see, the important stuff here is the value of the 'on' parameter. : "sw:/workflowA\/1_workflowB\/2/"

How does it work ?

Well, when the SWValidator is enabled, it is called when a transition is done and validates the 'status' attribute ... but that's not all ! It will also creates a scenario name and apply all validations rules defined for this scenario.
The scenario name created by SWValidator is built by concatenating, the start status, the underscore character , and the target status. In this case, the scenario will be : "workflowA/1_workflowB/2"

... so why not use this scenario name instead of this strange string with backslashes and stuff ?

Well, this is because you have decided to set the match parameter to true. In this case, SWValidator will consider the value of the 'on' parameter as a regular expression, and it will try to match the scenario name it creates for the transition, with this regular expression. (Note that the "sw:" prefix is only here to prevent scenario collision)

So for the example above we would have :

my record goes from workflowA/1 to workflowB/2

the SWValidator is invoked and creates the scenario name "workflowA/1_workflowB/2"

SWValidator will check each validation rule with a 'on' attribute and a scenario name starting with "sw:"

for each one found, it will test if it matches "workflowA/1_workflowB/2" and if yes, it apply the validation rule

To create a regular expression that matches the string "workflowA/1_workflowB/2" you must escape the slash character ... that's why a backslash is needed (this is a nice page to tests regular expression ).

One last word : if you don't need the match feature, you could have wrote your rules like this :

that is I want that automatically status go in C if destination status is B but the problem is that $event don't change and go in loop... because $event->destination result always B!!! is normal this situation??? what is wrong?
i hope my question is clear and you have an answare
thank you so much!!!

Hi Salsero,
I thought that sooner or later, such a question was going to be asked .....and you are the winner !!

I understand what you are trying to do : automatically change the status from within a transition, and unfortunatly this is not possible ... by design.
The reason is that even if you're changing the status to C afterTransition, you are still in the process of completing the transition, and starting another transition at this point would indeed result in a loop (however I thought I wrote something to prevent infinite recusive loop for such situation ... I'll take a look).
Anyway, if you want to implement such behavior, you should set status to C form outside any simpleWorkflow function. Maybe you could try to do it in afterSave ... that's something to try (with no warranty).

Sorry for the inconvenience. I hope you'll find a way to bypass this limitation.

Hello!!!
ok no problem.. I have bypassed the problem in this way and seems to work:
i'm using another flowchart (second);
when the first flowchart go in status B, it change status in the second flowchart;
after transition of second flowchart; this last set the status "C" in the first;

i don't know if it will be a solution because i'm finishing to implement it
but in theory should go

I'm using simpleWorkflow and very happy to have installed it. It does the job I need without much head-scratching.
Thanks.

Now, I'm looking for an advice here. I have my workflow set and I want to keep a single view action in my controller (clean and reusable).
But, based on the current status, I'd like to render a different partial.
To do this, I've added a method to my model that returns the needed partial for each status, like this:

I have installed and tested your simple workflow with the default blog app and it was successful. Any specific changes required or not if i want to integrate it with YiiBoilerplate? I have tried to configure your extension and so far i have no clue why i cannot call static function from SWHelper? I suspected the behavior was not loaded thus any function in SWActiveRecordBehavior cannot be called. Please shed some light....

Sorry, just realize you on vacation ..... Hope u can reply when u come back....