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