[BUGFIX] Do not fetch extension list on every request
[Packages/TYPO3.CMS.git] / typo3 / sysext / extensionmanager / Classes / Domain / Model / Repository.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2010 Marcus Krause <marcus#exp2010@t3sec.info>
6 * Steffen Kamper <info@sk-typo3.de>
7 * All rights reserved
8 *
9 * This script is part of the TYPO3 project. The TYPO3 project is
10 * free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * The GNU General Public License can be found at
16 * http://www.gnu.org/copyleft/gpl.html.
17 *
18 * This script is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * This copyright notice MUST APPEAR in all copies of the script!
24 ***************************************************************/
25
26 /**
27 * Repository object for extension manager.
28 *
29 * @author Marcus Krause <marcus#exp2010@t3sec.info>
30 * @author Steffen Kamper <info@sk-typo3.de>
31 *
32 * @since 2010-02-11
33 * @package Extension Manager
34 * @subpackage Model
35 */
36 class Tx_Extensionmanager_Domain_Model_Repository extends Tx_Extbase_DomainObject_AbstractEntity {
37
38 /**
39 * Keeps repository title.
40 *
41 * @var string
42 */
43 protected $title;
44
45 /**
46 * Keeps repository description.
47 *
48 * @var string
49 */
50 protected $description;
51
52 /**
53 * Keeps mirror list URL.
54 *
55 * @var string
56 */
57 protected $mirrorListUrl;
58
59 /**
60 * Keeps repository mirrors object.
61 *
62 * @var Tx_Extensionmanager_Domain_Model_Mirrors
63 */
64 protected $mirrors;
65
66 /**
67 * Keeps wsdl URL.
68 *
69 * @var string
70 */
71 protected $wsdlUrl;
72
73 /**
74 * Keeps last update.
75 *
76 * @var DateTime
77 */
78 protected $lastUpdate;
79
80 /**
81 * Keeps extension count.
82 *
83 * @var string
84 */
85 protected $extensionCount;
86
87 /**
88 * Method returns title of a repository.
89 *
90 * @access public
91 * @return string title of repository
92 * @see $title, setTitle()
93 */
94 public function getTitle() {
95 return $this->title;
96 }
97
98 /**
99 * Method sets title of a repository.
100 *
101 * @access public
102 * @param string $title title of repository to set
103 * @return void
104 * @see $title, getTitle()
105 */
106 public function setTitle($title) {
107 if (!empty($title) && is_string($title)) {
108 $this->title = $title;
109 }
110 }
111
112 /**
113 * Method returns description of a repository.
114 *
115 * @access public
116 * @return string title of repository
117 * @see $title, setTitle()
118 */
119 public function getDescription() {
120 return $this->description;
121 }
122
123 /**
124 * Method sets description of a repository.
125 *
126 * @access public
127 * @param string $description title of repository to set
128 * @return void
129 */
130 public function setDescription($description) {
131 if (!empty($description) && is_string($description)) {
132 $this->description = $description;
133 }
134 }
135
136 /**
137 * Method returns URL of a resource that contains repository mirrors.
138 *
139 * @access public
140 * @return string URL of file that contains repository mirros
141 * @see $mirrorListUrl, getMirrorListUrl()
142 */
143 public function getMirrorListUrl() {
144 return $this->mirrorListUrl;
145 }
146
147 /**
148 * Method sets URL of a resource that contains repository mirrors.
149 *
150 * Parameter is typically a remote gzipped xml file.
151 *
152 * @access public
153 * @param string $url URL of file that contains repository mirrors
154 * @return void
155 * @see $mirrorListUrl, getMirrorListUrl()
156 */
157 public function setMirrorListUrl($url) {
158 if (empty($url) || (!empty($url) && t3lib_div::isValidUrl($url))) {
159 $this->mirrorListUrl = $url;
160 }
161 }
162
163 /**
164 * Method returns URL of repository WSDL.
165 *
166 * @access public
167 * @return string URL of repository WSDL
168 * @see $wsdlUrl, setWsdlUrl()
169 */
170 public function getWsdlUrl() {
171 return $this->wsdlUrl;
172 }
173
174 /**
175 * Method sets URL of repository WSDL.
176 *
177 * @param string $url URL of repository WSDL
178 * @return void
179 * @see $wsdlUrl, getWsdlUrl()
180 */
181 public function setWsdlUrl($url) {
182 if (!empty($url) && t3lib_div::isValidUrl($url)) {
183 $this->wsdlUrl = $url;
184 }
185 }
186
187 /**
188 * Method returns LastUpdate.
189 *
190 * @access public
191 * @return DateTime timestamp of last update
192 */
193 public function getLastUpdate() {
194 return $this->lastUpdate;
195 }
196
197 /**
198 * Method sets LastUpdate.
199 *
200 * @access public
201 * @param DateTime $time URL of repository WSDL
202 * @return void
203 */
204 public function setLastUpdate(DateTime $time) {
205 $this->lastUpdate = $time;
206 }
207
208 /**
209 * Method returns extension count
210 *
211 * @access public
212 * @return int count of read extensions
213 */
214 public function getExtensionCount() {
215 return $this->extensionCount;
216 }
217
218 /**
219 * Method sets extension count
220 *
221 * @access public
222 * @param string $count count of read extensions
223 * @return void
224 */
225 public function setExtensionCount($count) {
226 $this->extensionCount = $count;
227 }
228
229 /**
230 * Method registers repository mirrors object.
231 *
232 * Repository mirrors object is passed by reference.
233 *
234 * @access public
235 * @param Tx_Extensionmanager_Domain_Model_Mirrors $mirrors mirror list
236 * @return void
237 * @see $mirrors, getMirrors(), hasMirrors(), removeMirrors()
238 */
239 public function addMirrors(Tx_Extensionmanager_Domain_Model_Mirrors $mirrors) {
240 $this->mirrors = $mirrors;
241 }
242
243 /**
244 * Method returns information if a repository mirrors
245 * object has been registered to this repository.
246 *
247 * @access public
248 * @return boolean TRUE, if a repository mirrors object has been registered, otherwise FALSE
249 * @see $mirrors, addMirrors(), getMirrors(), removeMirrors()
250 */
251 public function hasMirrors() {
252 $hasMirrors = FALSE;
253 if (is_object($this->mirrors)) {
254 $hasMirrors = TRUE;
255 }
256 return $hasMirrors;
257 }
258
259 /**
260 * Method returns a repository mirrors object.
261 *
262 * @access public
263 * @return Tx_Extensionmanager_Domain_Model_Mirrors mirrors for repository
264 * @see $mirrors, addMirrors(), hasMirrors(), removeMirrors()
265 */
266 public function getMirrors() {
267 return $this->hasMirrors() ? $this->mirrors : NULL;
268 }
269
270 /**
271 * Method unregisters a repository mirrors object.
272 *
273 * @access public
274 * @return void
275 * @see $mirrors, addMirrors(), getMirrors(), hasMirrors()
276 */
277 public function removeMirrors() {
278 unset($this->mirrors);
279 }
280 }
281
282 ?>