-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathREADME
132 lines (95 loc) · 3.37 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
sfDoctrineActAsActivablePlugin
=============================
The `sfDoctrineActAsActivablePlugin` is a symfony plugin that allows use of the doctrine behavior actAsActivable.
This behavior provides methods on your model for setting "is active"/"is not active" state to doctrine records.
This plugin allow cascade activate/desactivate between doctrine relation
Installation
------------
* Install the plugin
$ symfony plugin:install sfDoctrineActAsActivablePlugin
* Activate the plugin in your project configuration file (in config/ProjectConfiguration.class.php)
and enable the Doctrine callbaks.
class ProjectConfiguration extends sfProjectConfiguration
{
public function setup()
{
//...
$this->enablePlugins('sfDoctrineActAsActivablePlugin');
}
public function configureDoctrine(Doctrine_Manager $manager)
{
// Enable callbacks so that Activable behavior can be used
$manager->setAttribute(Doctrine_Core::ATTR_USE_DQL_CALLBACKS, true);
}
}
}
* Apply the behavior to your model in your schema file `config/doctrine/schema.yml`, ie:
# simple
[yml]
model:
actAs: [Activable]
# advenced
[yml]
model:
actAs:
Activable:
name: is_active
alias: ~
options:
default: true
indexName: activable
cascade:
down: true
* (optional): If you prefer apply a general config for all your activable model, leave activable
declaration in your schema with "~" and set the default config in your app.yml
# config/doctrine/schema.yml
Mymodel:
actAs:
Activable: ~
# app/myapp/config/app.yml
all:
activable:
name: is_active
alias: null
type: boolean
length: 1
options:
default: true
indexName: activable
cascade:
down: false
up: false
* Rebuild your models and database
$ symfony doctrine:build-all-reload
alternatively you could build the models, the sql, then run the sql manually
* Clear your cache
$ symfony cc
* when working with activale behavior , you will probably want to show all your
records (active and non-active) to be able to enable the "non-active"
items. To do that without adding a condition in your DQL, you can force the behavior
with:
// put this line before building your Doctrine Query
sfConfig::set('activable_dql_select', FALSE);
(comming soon)
Available schema options:
------------------------
[yml]
model:
actAs:
Activable:
cascade:
up: true
Available Record Methods
------------------------
* activate
[php]
$record->activate();
* desactivate
[php]
$record->deactivate();
* fullActivate
[php]
$record->fullActivate();
* fullDesactivate
[php]
$record->fullDeactivate();