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