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