[TASK] Add unit test to cover stdWrap_innerWrap
[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 \TYPO3\CMS\Backend\ContextMenu\ContextMenuActionCollection
61 */
62 protected $childActions = null;
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 \TYPO3\CMS\Backend\ContextMenu\ContextMenuActionCollection
177 */
178 public function getChildActions()
179 {
180 return $this->childActions;
181 }
182
183 /**
184 * Sets the child actions
185 *
186 * @param \TYPO3\CMS\Backend\ContextMenu\ContextMenuActionCollection $actions
187 * @return void
188 */
189 public function setChildActions(\TYPO3\CMS\Backend\ContextMenu\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 if ($this->childActions !== null) {
202 return true;
203 }
204 return false;
205 }
206
207 /**
208 * Sets the custom attributes
209 *
210 * @param array $customAttributes
211 * @return void
212 */
213 public function setCustomAttributes(array $customAttributes)
214 {
215 $this->customAttributes = $customAttributes;
216 }
217
218 /**
219 * Returns the custom attributes
220 *
221 * @return array
222 */
223 public function getCustomAttributes()
224 {
225 return $this->customAttributes;
226 }
227
228 /**
229 * Returns the action as an array
230 *
231 * @return array
232 */
233 public function toArray()
234 {
235 $arrayRepresentation = array(
236 'label' => $this->getLabel(),
237 'id' => $this->getId(),
238 'icon' => $this->getIcon(),
239 'callbackAction' => $this->getCallbackAction(),
240 'type' => $this->getType(),
241 'customAttributes' => $this->getCustomAttributes()
242 );
243 $arrayRepresentation['childActions'] = '';
244 if ($this->hasChildActions()) {
245 $arrayRepresentation['childActions'] = $this->childActions->toArray();
246 }
247 return $arrayRepresentation;
248 }
249 }