1 | <?php |
||
31 | abstract class Action extends \Grido\Components\Component |
||
32 | 1 | { |
|
33 | const ID = 'actions'; |
||
34 | |||
35 | /** @var Html <a> html tag */ |
||
36 | protected $elementPrototype; |
||
37 | |||
38 | /** @var callback for custom rendering */ |
||
39 | protected $customRender; |
||
40 | |||
41 | 1 | /** @var string - name of primary key f.e.: link->('Article:edit', array($primaryKey => 1)) */ |
|
42 | protected $primaryKey; |
||
43 | |||
44 | /** @var callback for disabling */ |
||
45 | protected $disable; |
||
46 | |||
47 | /** @var string */ |
||
48 | protected $options; |
||
49 | |||
50 | /** |
||
51 | * @param \Grido\Grid $grid |
||
52 | * @param string $name |
||
53 | * @param string $label |
||
54 | */ |
||
55 | public function __construct($grid, $name, $label) |
||
62 | |||
63 | /** |
||
64 | * Sets html element. |
||
65 | * @param Html $elementPrototype |
||
66 | * @return Action |
||
67 | */ |
||
68 | public function setElementPrototype(Html $elementPrototype) |
||
73 | |||
74 | /** |
||
75 | * Sets callback for custom rendering. |
||
76 | * @param callback |
||
77 | * @return Action |
||
78 | */ |
||
79 | public function setCustomRender($callback) |
||
84 | |||
85 | /** |
||
86 | * Sets primary key. |
||
87 | * @param string $primaryKey |
||
88 | * @return Action |
||
89 | */ |
||
90 | public function setPrimaryKey($primaryKey) |
||
95 | |||
96 | /** |
||
97 | * Sets callback for disable. |
||
98 | * Callback should return TRUE if the action is not allowed for current item. |
||
99 | * @param callback |
||
100 | * @return Action |
||
101 | */ |
||
102 | public function setDisable($callback) |
||
107 | |||
108 | /** |
||
109 | * Sets client side confirm. |
||
110 | * @param string|callback $confirm |
||
111 | * @return Action |
||
112 | */ |
||
113 | public function setConfirm($confirm) |
||
118 | |||
119 | /** |
||
120 | * Sets name of icon. |
||
121 | * @param string $name |
||
122 | * @return Action |
||
123 | */ |
||
124 | public function setIcon($name) |
||
129 | |||
130 | /** |
||
131 | * Sets user-specific option. |
||
132 | * @param string $key |
||
133 | * @param mixed $value |
||
134 | * @return Action |
||
135 | */ |
||
136 | public function setOption($key, $value) |
||
147 | |||
148 | /**********************************************************************************************/ |
||
149 | |||
150 | /** |
||
151 | * Returns element prototype (<a> html tag). |
||
152 | * @return Html |
||
153 | * @throws Exception |
||
154 | */ |
||
155 | public function getElementPrototype() |
||
169 | |||
170 | /** |
||
171 | * @return string |
||
172 | * @internal |
||
173 | */ |
||
174 | public function getPrimaryKey() |
||
182 | |||
183 | /** |
||
184 | * @param mixed $row |
||
185 | * @return Html |
||
186 | * @internal |
||
187 | */ |
||
188 | public function getElement($row) |
||
206 | |||
207 | /** |
||
208 | * Returns user-specific option. |
||
209 | * @param string $key |
||
210 | * @param mixed $default |
||
211 | * @return mixed |
||
212 | */ |
||
213 | public function getOption($key, $default = NULL) |
||
219 | |||
220 | /** |
||
221 | * Returns user-specific options. |
||
222 | * @return array |
||
223 | */ |
||
224 | public function getOptions() |
||
228 | |||
229 | /**********************************************************************************************/ |
||
230 | |||
231 | /** |
||
232 | * @param mixed $row |
||
233 | * @throws Exception |
||
234 | * @return void |
||
235 | */ |
||
236 | public function render($row) |
||
251 | } |
||
252 |