6a1890be5eba5d828f8bc8b14d74308a76e1c9b9
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Classes / ContextMenu / ContextMenuAction.php
1 <?php
2 namespace TYPO3\CMS\Backend\ContextMenu;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 /**
18 * Context Menu Action
19 */
20 class ContextMenuAction {
21
22 /**
23 * Label
24 *
25 * @var string
26 */
27 protected $label = '';
28
29 /**
30 * Identifier
31 *
32 * @var string
33 */
34 protected $id = '';
35
36 /**
37 * Icon
38 *
39 * @var string
40 */
41 protected $icon = '';
42
43 /**
44 * Class
45 *
46 * @var string
47 */
48 protected $class = '';
49
50 /**
51 * Callback Action
52 *
53 * @var string
54 */
55 protected $callbackAction = '';
56
57 /**
58 * Type
59 *
60 * @var string
61 */
62 protected $type = '';
63
64 /**
65 * Child Action Collection
66 *
67 * @var \TYPO3\CMS\Backend\ContextMenu\ContextMenuActionCollection
68 */
69 protected $childActions = NULL;
70
71 /**
72 * Custom Action Attributes
73 *
74 * @var array
75 */
76 protected $customAttributes = array();
77
78 /**
79 * Returns the label
80 *
81 * @return string
82 */
83 public function getLabel() {
84 return $this->label;
85 }
86
87 /**
88 * Sets the label
89 *
90 * @param string $label
91 */
92 public function setLabel($label) {
93 $this->label = $label;
94 }
95
96 /**
97 * Returns the identifier
98 *
99 * @return string
100 */
101 public function getId() {
102 return $this->id;
103 }
104
105 /**
106 * Sets the identifier
107 *
108 * @param string $id
109 */
110 public function setId($id) {
111 $this->id = $id;
112 }
113
114 /**
115 * Returns the icon
116 *
117 * @return string
118 */
119 public function getIcon() {
120 return $this->icon;
121 }
122
123 /**
124 * Sets the icon
125 *
126 * @param string $icon
127 * @return void
128 */
129 public function setIcon($icon) {
130 $this->icon = $icon;
131 }
132
133 /**
134 * Returns the class
135 *
136 * @return string
137 */
138 public function getClass() {
139 return $this->class;
140 }
141
142 /**
143 * Sets the class
144 *
145 * @param string $class
146 */
147 public function setClass($class) {
148 $this->class = $class;
149 }
150
151 /**
152 * Returns the callback action
153 *
154 * @return string
155 */
156 public function getCallbackAction() {
157 return $this->callbackAction;
158 }
159
160 /**
161 * Sets the callback action
162 *
163 * @param string $callbackAction
164 */
165 public function setCallbackAction($callbackAction) {
166 $this->callbackAction = $callbackAction;
167 }
168
169 /**
170 * Returns the type
171 *
172 * @return string
173 */
174 public function getType() {
175 return $this->type;
176 }
177
178 /**
179 * Sets the type
180 *
181 * @param string $type
182 * @return void
183 */
184 public function setType($type) {
185 $this->type = $type;
186 }
187
188 /**
189 * Returns the child actions
190 *
191 * @return \TYPO3\CMS\Backend\ContextMenu\ContextMenuActionCollection
192 */
193 public function getChildActions() {
194 return $this->childActions;
195 }
196
197 /**
198 * Sets the child actions
199 *
200 * @param \TYPO3\CMS\Backend\ContextMenu\ContextMenuActionCollection $actions
201 * @return void
202 */
203 public function setChildActions(\TYPO3\CMS\Backend\ContextMenu\ContextMenuActionCollection $actions) {
204 $this->childActions = $actions;
205 }
206
207 /**
208 * Returns TRUE if the action has child actions
209 *
210 * @return bool
211 */
212 public function hasChildActions() {
213 if ($this->childActions !== NULL) {
214 return TRUE;
215 }
216 return FALSE;
217 }
218
219 /**
220 * Sets the custom attributes
221 *
222 * @param array $customAttributes
223 * @return void
224 */
225 public function setCustomAttributes(array $customAttributes) {
226 $this->customAttributes = $customAttributes;
227 }
228
229 /**
230 * Returns the custom attributes
231 *
232 * @return array
233 */
234 public function getCustomAttributes() {
235 return $this->customAttributes;
236 }
237
238 /**
239 * Returns the action as an array
240 *
241 * @return array
242 */
243 public function toArray() {
244 $arrayRepresentation = array(
245 'label' => $this->getLabel(),
246 'id' => $this->getId(),
247 'icon' => $this->getIcon(),
248 'class' => $this->getClass(),
249 'callbackAction' => $this->getCallbackAction(),
250 'type' => $this->getType(),
251 'customAttributes' => $this->getCustomAttributes()
252 );
253 $arrayRepresentation['childActions'] = '';
254 if ($this->hasChildActions()) {
255 $arrayRepresentation['childActions'] = $this->childActions->toArray();
256 }
257 return $arrayRepresentation;
258 }
259
260 }