[TASK] EXT:lang CodeCleanup
[Packages/TYPO3.CMS.git] / typo3 / sysext / lang / Classes / Domain / Model / Extension.php
1 <?php
2 namespace TYPO3\CMS\Lang\Domain\Model;
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 use TYPO3\CMS\Core\Utility\VersionNumberUtility;
18 use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
19
20 /**
21 * Extension model
22 */
23 class Extension extends AbstractEntity
24 {
25 /**
26 * @var string
27 */
28 protected $key = '';
29
30 /**
31 * @var string
32 */
33 protected $title = '';
34
35 /**
36 * @var string
37 */
38 protected $icon = '';
39
40 /**
41 * @var int
42 */
43 protected $iconWidth = 28;
44
45 /**
46 * @var int
47 */
48 protected $iconHeight = 28;
49
50 /**
51 * @var int
52 */
53 protected $version = '';
54
55 /**
56 * @var array
57 */
58 protected $updateResult = array();
59
60 /**
61 * Constructor of the extension model.
62 *
63 * @param string $key The extension key
64 * @param string $title Title of the extension
65 * @param string $icon Icon representing the extension
66 */
67 public function __construct($key = '', $title= '', $icon = '')
68 {
69 $this->setKey($key);
70 $this->setTitle($title);
71 $this->setIcon($icon);
72 }
73
74 /**
75 * Setter for the icon
76 *
77 * @param string $icon ext_icon path relative to typo3 folder like ../typo3conf/ext/extensionkey/ext_icon.png
78 * @return void
79 */
80 public function setIcon($icon)
81 {
82 $this->icon = $icon;
83 }
84
85 /**
86 * Getter for the icon
87 *
88 * @return string ext_icon path relative to typo3 folder
89 */
90 public function getIcon()
91 {
92 return $this->icon;
93 }
94
95 /**
96 * @return int
97 */
98 public function getIconWidth()
99 {
100 return $this->iconWidth;
101 }
102
103 /**
104 * @param int $iconWidth
105 */
106 public function setIconWidth($iconWidth)
107 {
108 $this->iconWidth = $iconWidth;
109 }
110
111 /**
112 * @return int
113 */
114 public function getIconHeight()
115 {
116 return $this->iconHeight;
117 }
118
119 /**
120 * @param int $iconHeight
121 */
122 public function setIconHeight($iconHeight)
123 {
124 $this->iconHeight = $iconHeight;
125 }
126
127 /**
128 * Setter for the key
129 *
130 * @param string $key
131 * @return void
132 */
133 public function setKey($key)
134 {
135 $this->key = $key;
136 }
137
138 /**
139 * Getter for the key
140 *
141 * @return string
142 */
143 public function getKey()
144 {
145 return $this->key;
146 }
147
148 /**
149 * Setter for the title
150 *
151 * @param string $title
152 * @return void
153 */
154 public function setTitle($title)
155 {
156 $this->title = $title;
157 }
158
159 /**
160 * Getter for the title
161 *
162 * @return string
163 */
164 public function getTitle()
165 {
166 return $this->title;
167 }
168
169 /**
170 * Setter for the version
171 *
172 * @param int $version Needs to have a valid version format like 1003007
173 * @return void
174 */
175 public function setVersion($version)
176 {
177 $this->version = $version;
178 }
179
180 /**
181 * Setter for the version from string
182 *
183 * @param string $version Needs to have a format like '1.3.7' and converts it into an integer like 1003007 before setting the version
184 * @see \TYPO3\CMS\Core\Utility\VersionNumberUtility::convertVersionNumberToInteger
185 * @return void
186 */
187 public function setVersionFromString($version)
188 {
189 $this->version = VersionNumberUtility::convertVersionNumberToInteger($version);
190 }
191
192 /**
193 * Getter for the version
194 *
195 * @return int interpretation of the extension version
196 */
197 public function getVersion()
198 {
199 return $this->version;
200 }
201
202 /**
203 * Setter for updateResult
204 *
205 * @param array $updateResult Needs to be in a structure like array('icon' => '', 'message' => '')
206 * @return void
207 */
208 public function setUpdateResult($updateResult)
209 {
210 $this->updateResult = (array)$updateResult;
211 }
212
213 /**
214 * Getter for updateResult
215 *
216 * @return array returns the update result as an array in the structure like array('icon' => '', 'message' => '')
217 */
218 public function getUpdateResult()
219 {
220 return $this->updateResult;
221 }
222
223 /**
224 * Returns an array represetation of current model
225 *
226 * @return array The properties
227 */
228 public function toArray()
229 {
230 return array(
231 'key' => $this->getKey(),
232 'title' => $this->getTitle(),
233 'icon' => $this->getIcon(),
234 'version' => $this->getVersion(),
235 'width' => $this->getIconWidth(),
236 'height' => $this->getIconHeight()
237 );
238 }
239 }