[!!!][TASK] Cleanup ContextMenu classes
[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 * Callback Action
45 *
46 * @var string
47 */
48 protected $callbackAction = '';
49
50 /**
51 * Type
52 *
53 * @var string
54 */
55 protected $type = '';
56
57 /**
58 * Child Action Collection
59 *
60 * @var ContextMenuActionCollection
61 */
62 protected $childActions;
63
64 /**
65 * Custom Action Attributes
66 *
67 * @var array
68 */
69 protected $customAttributes = array();
70
71 /**
72 * Returns the label
73 *
74 * @return string
75 */
76 public function getLabel()
77 {
78 return $this->label;
79 }
80
81 /**
82 * Sets the label
83 *
84 * @param string $label
85 */
86 public function setLabel($label)
87 {
88 $this->label = $label;
89 }
90
91 /**
92 * Returns the identifier
93 *
94 * @return string
95 */
96 public function getId()
97 {
98 return $this->id;
99 }
100
101 /**
102 * Sets the identifier
103 *
104 * @param string $id
105 */
106 public function setId($id)
107 {
108 $this->id = $id;
109 }
110
111 /**
112 * Returns the icon
113 *
114 * @return string
115 */
116 public function getIcon()
117 {
118 return $this->icon;
119 }
120
121 /**
122 * Sets the icon
123 *
124 * @param string $icon
125 * @return void
126 */
127 public function setIcon($icon)
128 {
129 $this->icon = $icon;
130 }
131
132 /**
133 * Returns the callback action
134 *
135 * @return string
136 */
137 public function getCallbackAction()
138 {
139 return $this->callbackAction;
140 }
141
142 /**
143 * Sets the callback action
144 *
145 * @param string $callbackAction
146 */
147 public function setCallbackAction($callbackAction)
148 {
149 $this->callbackAction = $callbackAction;
150 }
151
152 /**
153 * Returns the type
154 *
155 * @return string
156 */
157 public function getType()
158 {
159 return $this->type;
160 }
161
162 /**
163 * Sets the type
164 *
165 * @param string $type
166 * @return void
167 */
168 public function setType($type)
169 {
170 $this->type = $type;
171 }
172
173 /**
174 * Returns the child actions
175 *
176 * @return ContextMenuActionCollection
177 */
178 public function getChildActions()
179 {
180 return $this->childActions;
181 }
182
183 /**
184 * Sets the child actions
185 *
186 * @param ContextMenuActionCollection $actions
187 * @return void
188 */
189 public function setChildActions(ContextMenuActionCollection $actions)
190 {
191 $this->childActions = $actions;
192 }
193
194 /**
195 * Returns TRUE if the action has child actions
196 *
197 * @return bool
198 */
199 public function hasChildActions()
200 {
201 return $this->childActions !== null;
202 }
203
204 /**
205 * Sets the custom attributes
206 *
207 * @param array $customAttributes
208 * @return void
209 */
210 public function setCustomAttributes(array $customAttributes)
211 {
212 $this->customAttributes = $customAttributes;
213 }
214
215 /**
216 * Returns the custom attributes
217 *
218 * @return array
219 */
220 public function getCustomAttributes()
221 {
222 return $this->customAttributes;
223 }
224
225 /**
226 * Returns the action as an array
227 *
228 * @return array
229 */
230 public function toArray()
231 {
232 $arrayRepresentation = array(
233 'label' => $this->getLabel(),
234 'id' => $this->getId(),
235 'icon' => $this->getIcon(),
236 'callbackAction' => $this->getCallbackAction(),
237 'type' => $this->getType(),
238 'customAttributes' => $this->getCustomAttributes()
239 );
240 $arrayRepresentation['childActions'] = '';
241 if ($this->hasChildActions()) {
242 $arrayRepresentation['childActions'] = $this->childActions->toArray();
243 }
244 return $arrayRepresentation;
245 }
246 }