Yii Framework Forum: [EXTENSION] simpleWorkflow - Yii Framework Forum

Jump to content

  • (8 Pages)
  • +
  • « First
  • 6
  • 7
  • 8
  • You cannot start a new topic
  • You cannot reply to this topic

[EXTENSION] simpleWorkflow a small workflow handler for models Rate Topic: ***** 3 Votes

#141 User is offline   Ferllings 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 11
  • Joined: 14-November 10

Posted 10 July 2013 - 02:54 AM

View PostRaoul, on 09 July 2013 - 01:39 PM, said:

Could you please elaborate on the use case that would require such behavior ? ... maybe that could help me understand how to solve your problem using the current implementation.



Yes, I'll try to explain it.

I have an application for a client, where guest users can send request (via a form), with a category type (art, music, special, etc...)
The request goes into the workflow process from (1)new, (2)in process, (3)accepted, (4)closed.

But my client wants now to have an extra step, if the category is 'special'.
So for this special category, the workflow will be: (1)new, (2)in process, (3)accepted, (4)director accepted, (5)closed.
0

#142 User is offline   Ankit Modi 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 866
  • Joined: 19-February 13
  • Location:India

Posted 10 July 2013 - 07:11 AM

Hi,

Thanks...it's may helpful...
Thanks,
Ankit Modi
Skype : amodi06
0

#143 User is offline   Ferllings 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 11
  • Joined: 14-November 10

Posted 12 July 2013 - 03:07 AM

Any idea?

View PostFerllings, on 10 July 2013 - 02:54 AM, said:

Yes, I'll try to explain it.

I have an application for a client, where guest users can send request (via a form), with a category type (art, music, special, etc...)
The request goes into the workflow process from (1)new, (2)in process, (3)accepted, (4)closed.

But my client wants now to have an extra step, if the category is 'special'.
So for this special category, the workflow will be: (1)new, (2)in process, (3)accepted, (4)director accepted, (5)closed.

0

#144 User is offline   Raoul 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 636
  • Joined: 29-November 08
  • Location:Paris, France

Posted 15 July 2013 - 03:09 PM

Hi,
sorry for the late reply (I was on holidays ;) )
I understand better now.

One simple solution would be to implement the logic not in the workflow itself, but in your php code (e.g. test the value of the 'category' attribute and if it is equal to "special", set the status to "director accepted", otheriwse "closed".

Another option that would require minimal workflow change (one additional status "director accepted" and 2 transitions) would be to use the simpleWorkflow Validator. This requires you to validate the model prior to saving. Moreover you should first assume that 'director accepted' status can be reached and if it's not the case (validation fails) set the status to 'closed'.

Take a look to this schema. Validation rule 1 will allow an 'accepted' model to go to 'closed' only if 'category' != 'special'. In this case the only transition possible would then be to the 'diraccepted' status.
In the same way validation rule 2 would allow a 'diraccepted' model to be sent into the 'closed' status only if 'category' == 'special' .... but note that this second validation rule is optional as if the first validation rules was correctly tested, the model in "diraccepted' is garanteed to have 'category' == 'special'.

(read more about workflow driven validation)

I could not test it any further but you can give it a try and let me know if it works as expected

At last, and as you wrote, another option would be to create a brand new workflow and insert the model into it, only if it has the 'category' attribute equals to 'special'. Note that in this case you can't use the 'autoInsert' = true option.

hope it helps
ciao
B)
0

#145 User is offline   Raoul 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 636
  • Joined: 29-November 08
  • Location:Paris, France

Posted 29 August 2013 - 10:14 AM

Hi all,
just a short update to inform that the simpleWorkflow Extension has a new home !! .. so you're all invited to visite the

New simpleWorkflow Home Page

(of course it is made with Yii 1.1.14, and some cool extensions like YiiStrap, YiiWheels)


ciao
8)
0

#146 User is offline   Bui Sy Nguyen 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 12-September 13

Posted 25 November 2013 - 07:12 AM

Thank you Raoul, you saved my weeks of coding...
0

#147 User is offline   Raoul 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 636
  • Joined: 29-November 08
  • Location:Paris, France

Posted 27 November 2013 - 09:12 AM

:) good to hear ... you're welcome

B)
0

#148 User is offline   HanTomi 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 17-July 13

Posted 17 December 2013 - 05:44 AM

Dear Raoul!

First of all I would like to thank you this extension.

For my current work I got an existing database, what I can't modify :(

In every table has a statusID attribute (INT) and these tables has a relation:
'status' => array(self::BELONGS_TO, 'Status', 'statusID'),

The status table:
status(id, name, description)

My question: Is it possible to use statusID (INT) instead of using varchar(45), OR to use the status->name attribute inside the workflow definition and swNextStatus() method?

Thanks in advanced.

Tom
0

#149 User is offline   Raoul 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 636
  • Joined: 29-November 08
  • Location:Paris, France

Posted 29 January 2014 - 06:03 AM

Hi Tom,
sorry for the late reply but I did not received any forum notification that a new messages had been posted in this thread ..

Anyway, the reply to your first question is "no" : the status must have the following format : workflowId/statusName (e.g. 'post/published') so it can't be stored as in integer.

Unfortunatly, it is not possible to use a relation to retrieve the status name from another table. When the simpleWorkflow behavior is attached to a model, it first test if the 'status' attribute (default name) belongs to the model. The "status' attribute is then used to read/write status value ... so using a relation will not work.

Sorry to say that in the current version I see no way to solve this.

ciao
8)
0

#150 User is offline   kay 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 21
  • Joined: 14-July 11

Posted 11 July 2014 - 02:14 AM

Hi Roul ..

I am glad this extensions really help me at work and easy to use;

but, i had seen in vimeo video that i can include a function in transition ?

how do i define this function ? correct me if am wrong

will you explain ? . or i must define it by myself on my update controller ??

thank
0

#151 User is offline   Raoul 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 636
  • Joined: 29-November 08
  • Location:Paris, France

Posted 12 July 2014 - 11:59 AM

hi Kay,
glad to know that the simpleWorkflow Extension helped you.

Regarding the function that you can call in a transition, yes you're right, this is a feature of the simpleWorkflow extension. Such function is called a "transition task" and it is executed when a model is going through a transition.

To define a transition task, you have to simple add it in your workflow definition.

Take a look to this example and you'll get a better idea. Note that if your transition task refers to $this, then it is assumed to be related to the model if your workflow is defined as a PHP array. If it is defined as a PHP class, $this is the workflow instance itself (just like inthis example).

hope its helped.
ciao
B)
0

Share this topic:


  • (8 Pages)
  • +
  • « First
  • 6
  • 7
  • 8
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users