This repository has been archived by the owner on May 14, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME
70 lines (48 loc) · 1.6 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
Acts as Statemachine Plugin
===================================
This plugin is inspired by:
http://elitists.textdriven.com/svn/plugins/acts_as_state_machine/trunk
Allows definition of states and transition between states.
Ideal for generating workflows.
Usage Examples
----------------
class Order extends ActiveRecord
{
var $acts_as = array('statemachine'=>array('initial'=>'openend',
'states'=>array('opened',
'closed'=>array('enter'=>'sendEmail'),
'returned')));
function close()
{
$this->transition('opened','closed');
}
function returnOrder()
{
$this->transition('closed','returned');
}
function sendEmail()
{
Mailer::sendNotice($this);
}
}
Will take the value of $myModel->name and generate $myModel->slug.
class MyModel extends ActiveRecord
{
var $acts_as = array('sluggable'=>array('slug_source'=>'getSlugName','slug_target'=>'slug'));
function getSlugName()
{
return $this->name.' '.$this->number;
}
}
$order = new Order();
$order->close(); // notice is sent by mailer
$order->returnOrder();
Installation
--------------------------------
./script/plugin install acts_as_statemachine
Credits
-------
Inspired by: http://elitists.textdriven.com/svn/plugins/acts_as_state_machine/trunk
Future
--------
See TODO file to know what will be implemented into future versions of this plugin.