1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* admin |
5
|
|
|
* |
6
|
|
|
* @category Apparat |
7
|
|
|
* @package Apparat\Server |
8
|
|
|
* @subpackage Tollwerk\Admin\Infrastructure\Model |
9
|
|
|
* @author Joschi Kuphal <[email protected]> / @jkphl |
10
|
|
|
* @copyright Copyright © 2016 Joschi Kuphal <[email protected]> / @jkphl |
11
|
|
|
* @license http://opensource.org/licenses/MIT The MIT License (MIT) |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
/*********************************************************************************** |
15
|
|
|
* The MIT License (MIT) |
16
|
|
|
* |
17
|
|
|
* Copyright © 2016 Joschi Kuphal <[email protected]> / @jkphl |
18
|
|
|
* |
19
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of |
20
|
|
|
* this software and associated documentation files (the "Software"), to deal in |
21
|
|
|
* the Software without restriction, including without limitation the rights to |
22
|
|
|
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of |
23
|
|
|
* the Software, and to permit persons to whom the Software is furnished to do so, |
24
|
|
|
* subject to the following conditions: |
25
|
|
|
* |
26
|
|
|
* The above copyright notice and this permission notice shall be included in all |
27
|
|
|
* copies or substantial portions of the Software. |
28
|
|
|
* |
29
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
30
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS |
31
|
|
|
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR |
32
|
|
|
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER |
33
|
|
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
34
|
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
35
|
|
|
***********************************************************************************/ |
36
|
|
|
|
37
|
|
|
namespace Tollwerk\Admin\Infrastructure\Model; |
38
|
|
|
|
39
|
|
|
use Tollwerk\Admin\Infrastructure\App; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Virtual host model |
43
|
|
|
* |
44
|
|
|
* @package Tollwerk\Admin |
45
|
|
|
* @subpackage Tollwerk\Admin\Infrastructure |
46
|
|
|
* @Entity |
47
|
|
|
* @Table(name="vhost") |
48
|
|
|
*/ |
49
|
|
|
class Vhost |
50
|
|
|
{ |
51
|
|
|
/** |
52
|
|
|
* Virtual host ID |
53
|
|
|
* |
54
|
|
|
* @var integer |
55
|
|
|
* @Id @Column(type="integer") |
56
|
|
|
* @GeneratedValue |
57
|
|
|
*/ |
58
|
|
|
protected $id; |
59
|
|
|
/** |
60
|
|
|
* Active |
61
|
|
|
* |
62
|
|
|
* @var boolean |
63
|
|
|
* @Column(type="boolean") |
64
|
|
|
*/ |
65
|
|
|
protected $active; |
66
|
|
|
/** |
67
|
|
|
* Account this domain is belonging to |
68
|
|
|
* |
69
|
|
|
* @var Account |
70
|
|
|
* @ManyToOne(targetEntity="Tollwerk\Admin\Infrastructure\Model\Account", inversedBy="vhosts") |
71
|
|
|
*/ |
72
|
|
|
protected $account; |
73
|
|
|
/** |
74
|
|
|
* Virtual host type |
75
|
|
|
* |
76
|
|
|
* @var string |
77
|
|
|
* @Column(type="enumvhosttype") |
78
|
|
|
*/ |
79
|
|
|
protected $type; |
80
|
|
|
/** |
81
|
|
|
* List of all associated domains |
82
|
|
|
* |
83
|
|
|
* @var Domain[] |
84
|
|
|
* @OneToMany(targetEntity="Tollwerk\Admin\Infrastructure\Model\Domain", mappedBy="account") |
85
|
|
|
*/ |
86
|
|
|
protected $domains; |
87
|
|
|
/** |
88
|
|
|
* Primary domain of this virtual host |
89
|
|
|
* |
90
|
|
|
* @var Domain |
91
|
|
|
*/ |
92
|
|
|
protected $primarydomain; |
93
|
|
|
/** |
94
|
|
|
* Document root directory |
95
|
|
|
* |
96
|
|
|
* @var string |
97
|
|
|
* @Column(length=128,unique=true) |
98
|
|
|
*/ |
99
|
|
|
protected $docroot; |
100
|
|
|
/** |
101
|
|
|
* HTTP Port |
102
|
|
|
* |
103
|
|
|
* @var int|null |
104
|
|
|
* @Column(type="integer", nullable=true, options={"unsigned":true, "default":80}) |
105
|
|
|
*/ |
106
|
|
|
protected $httpport; |
107
|
|
|
/** |
108
|
|
|
* HTTPS Port |
109
|
|
|
* |
110
|
|
|
* @var int|null |
111
|
|
|
* @Column(type="integer", nullable=true, options={"unsigned":true, "default":443}) |
112
|
|
|
*/ |
113
|
|
|
protected $httpsport; |
114
|
|
|
/** |
115
|
|
|
* Supported PHP version |
116
|
|
|
* |
117
|
|
|
* @var float|null |
118
|
|
|
* @Column(type="decimal",precision=2,scale=1,nullable=true) |
119
|
|
|
*/ |
120
|
|
|
protected $php; |
121
|
|
|
/** |
122
|
|
|
* Redirect URL |
123
|
|
|
* |
124
|
|
|
* @var string |
125
|
|
|
* @Column(length=128) |
126
|
|
|
*/ |
127
|
|
|
protected $redirecturl; |
128
|
|
|
/** |
129
|
|
|
* Redirect status |
130
|
|
|
* |
131
|
|
|
* @var int |
132
|
|
|
* @Column(type="integer", nullable=false, options={"unsigned":true, "default":301}) |
133
|
|
|
*/ |
134
|
|
|
protected $redirectstatus; |
135
|
|
|
|
136
|
|
|
/** |
137
|
|
|
* Return the vhost ID |
138
|
|
|
* |
139
|
|
|
* @return int Vhost ID |
140
|
|
|
*/ |
141
|
|
|
public function getId() |
142
|
|
|
{ |
143
|
|
|
return $this->id; |
144
|
|
|
} |
145
|
|
|
|
146
|
|
|
/** |
147
|
|
|
* Set the vhost ID |
148
|
|
|
* |
149
|
|
|
* @param int $id Vhost ID |
150
|
|
|
* @return Vhost |
151
|
|
|
*/ |
152
|
|
|
public function setId($id) |
153
|
|
|
{ |
154
|
|
|
$this->id = $id; |
155
|
|
|
return $this; |
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
/** |
159
|
|
|
* Set whether this is an active vhost |
160
|
|
|
* |
161
|
|
|
* @param boolean $active Active vhost |
162
|
|
|
* @return Vhost |
163
|
|
|
*/ |
164
|
|
|
public function setActive($active) |
165
|
|
|
{ |
166
|
|
|
$this->active = $active; |
167
|
|
|
return $this; |
168
|
|
|
} |
169
|
|
|
|
170
|
|
|
/** |
171
|
|
|
* Return whether the vhost is ative |
172
|
|
|
* |
173
|
|
|
* @return boolean Active vhost |
174
|
|
|
*/ |
175
|
|
|
public function isActive() |
176
|
|
|
{ |
177
|
|
|
return $this->active; |
178
|
|
|
} |
179
|
|
|
|
180
|
|
|
/** |
181
|
|
|
* Return the account this virtual host is belonging to |
182
|
|
|
* |
183
|
|
|
* @return Account Account |
184
|
|
|
*/ |
185
|
|
|
public function getAccount() |
186
|
|
|
{ |
187
|
|
|
return $this->account; |
188
|
|
|
} |
189
|
|
|
|
190
|
|
|
/** |
191
|
|
|
* Set the account this virtual host is belonging tp |
192
|
|
|
* |
193
|
|
|
* @param Account $account Account |
194
|
|
|
* @return Vhost Self reference |
195
|
|
|
*/ |
196
|
|
|
public function setAccount($account) |
197
|
|
|
{ |
198
|
|
|
$this->account = $account; |
199
|
|
|
return $this; |
200
|
|
|
} |
201
|
|
|
|
202
|
|
|
/** |
203
|
|
|
* Return the virtual host type |
204
|
|
|
* |
205
|
|
|
* @return string Virtual host type |
206
|
|
|
*/ |
207
|
|
|
public function getType() |
208
|
|
|
{ |
209
|
|
|
return $this->type; |
210
|
|
|
} |
211
|
|
|
|
212
|
|
|
/** |
213
|
|
|
* Set the virtual host type |
214
|
|
|
* |
215
|
|
|
* @param string $type Virtual host type |
216
|
|
|
* @return Vhost Self reference |
217
|
|
|
*/ |
218
|
|
|
public function setType($type) |
219
|
|
|
{ |
220
|
|
|
$this->type = $type; |
221
|
|
|
return $this; |
222
|
|
|
} |
223
|
|
|
|
224
|
|
|
/** |
225
|
|
|
* Return the associated domains |
226
|
|
|
* |
227
|
|
|
* @return Domain[] Associated domains |
228
|
|
|
*/ |
229
|
|
|
public function getDomains() |
230
|
|
|
{ |
231
|
|
|
return $this->domains; |
232
|
|
|
} |
233
|
|
|
|
234
|
|
|
/** |
235
|
|
|
* Set the associated domains |
236
|
|
|
* |
237
|
|
|
* @param Domain[] $domains Associated domains |
238
|
|
|
* @return Vhost Self reference |
239
|
|
|
*/ |
240
|
|
|
public function setDomains($domains) |
241
|
|
|
{ |
242
|
|
|
$this->domains = $domains; |
243
|
|
|
return $this; |
244
|
|
|
} |
245
|
|
|
|
246
|
|
|
/** |
247
|
|
|
* Return the primary domain of this virtual host |
248
|
|
|
* |
249
|
|
|
* @return Domain Primary domain |
250
|
|
|
*/ |
251
|
|
|
public function getPrimarydomain() |
252
|
|
|
{ |
253
|
|
|
if ($this->primarydomain === null) { |
254
|
|
|
$entityManager = App::getEntityManager(); |
255
|
|
|
$domainRepository = $entityManager->getRepository(Domain::class); |
256
|
|
|
$this->primarydomain = $domainRepository->findOneBy(['vhost' => $this->getId(), 'primarydomain' => 1]); |
257
|
|
|
} |
258
|
|
|
|
259
|
|
|
return $this->primarydomain; |
260
|
|
|
} |
261
|
|
|
|
262
|
|
|
/** |
263
|
|
|
* Set the primary domain of this virtual host |
264
|
|
|
* |
265
|
|
|
* @param Domain $primarydomain Primary domain |
266
|
|
|
* @return Vhost Self reference |
267
|
|
|
*/ |
268
|
|
|
public function setPrimarydomain($primarydomain) |
269
|
|
|
{ |
270
|
|
|
$this->primarydomain = $primarydomain; |
271
|
|
|
return $this; |
272
|
|
|
} |
273
|
|
|
|
274
|
|
|
/** |
275
|
|
|
* Return the document root |
276
|
|
|
* |
277
|
|
|
* @return string Document root |
278
|
|
|
*/ |
279
|
|
|
public function getDocroot() |
280
|
|
|
{ |
281
|
|
|
return $this->docroot; |
282
|
|
|
} |
283
|
|
|
|
284
|
|
|
/** |
285
|
|
|
* Set the document root |
286
|
|
|
* |
287
|
|
|
* @param string $docroot Document root |
288
|
|
|
* @return Vhost Self reference |
289
|
|
|
*/ |
290
|
|
|
public function setDocroot($docroot) |
291
|
|
|
{ |
292
|
|
|
$this->docroot = $docroot; |
293
|
|
|
return $this; |
294
|
|
|
} |
295
|
|
|
|
296
|
|
|
/** |
297
|
|
|
* Return the HTTP port |
298
|
|
|
* |
299
|
|
|
* @return int|null HTTP port |
300
|
|
|
*/ |
301
|
|
|
public function getHttpport() |
302
|
|
|
{ |
303
|
|
|
return $this->httpport; |
304
|
|
|
} |
305
|
|
|
|
306
|
|
|
/** |
307
|
|
|
* Set the HTTP port |
308
|
|
|
* |
309
|
|
|
* @param int|null $httpport HTTP port |
310
|
|
|
* @return Vhost Self reference |
311
|
|
|
*/ |
312
|
|
|
public function setHttpport($httpport) |
313
|
|
|
{ |
314
|
|
|
$this->httpport = $httpport; |
315
|
|
|
return $this; |
316
|
|
|
} |
317
|
|
|
|
318
|
|
|
/** |
319
|
|
|
* Return the HTTPS port |
320
|
|
|
* |
321
|
|
|
* @return int|null HTTPS port |
322
|
|
|
*/ |
323
|
|
|
public function getHttpsport() |
324
|
|
|
{ |
325
|
|
|
return $this->httpsport; |
326
|
|
|
} |
327
|
|
|
|
328
|
|
|
/** |
329
|
|
|
* Set the HTTPS port |
330
|
|
|
* |
331
|
|
|
* @param int|null $httpsport HTTPS port |
332
|
|
|
* @return Vhost |
333
|
|
|
*/ |
334
|
|
|
public function setHttpsport($httpsport) |
335
|
|
|
{ |
336
|
|
|
$this->httpsport = $httpsport; |
337
|
|
|
return $this; |
338
|
|
|
} |
339
|
|
|
|
340
|
|
|
/** |
341
|
|
|
* Return the supported PHP version |
342
|
|
|
* |
343
|
|
|
* @return float|null Supported PHP version |
344
|
|
|
*/ |
345
|
|
|
public function getPhp() |
346
|
|
|
{ |
347
|
|
|
return $this->php; |
348
|
|
|
} |
349
|
|
|
|
350
|
|
|
/** |
351
|
|
|
* Set the supported PHP version |
352
|
|
|
* |
353
|
|
|
* @param float|null $php Supported PHP version |
354
|
|
|
* @return Vhost Self reference |
355
|
|
|
*/ |
356
|
|
|
public function setPhp($php) |
357
|
|
|
{ |
358
|
|
|
$this->php = $php; |
359
|
|
|
return $this; |
360
|
|
|
} |
361
|
|
|
|
362
|
|
|
/** |
363
|
|
|
* Return the redirect URL |
364
|
|
|
* |
365
|
|
|
* @return string Redirect URL |
366
|
|
|
*/ |
367
|
|
|
public function getRedirecturl() |
368
|
|
|
{ |
369
|
|
|
return $this->redirecturl; |
370
|
|
|
} |
371
|
|
|
|
372
|
|
|
/** |
373
|
|
|
* Set the redirect URL |
374
|
|
|
* |
375
|
|
|
* @param string $redirecturl Redirect URL |
376
|
|
|
* @return Vhost Self reference |
377
|
|
|
*/ |
378
|
|
|
public function setRedirecturl($redirecturl) |
379
|
|
|
{ |
380
|
|
|
$this->redirecturl = $redirecturl; |
381
|
|
|
return $this; |
382
|
|
|
} |
383
|
|
|
|
384
|
|
|
/** |
385
|
|
|
* Return the redirect status |
386
|
|
|
* |
387
|
|
|
* @return int Redirect status |
388
|
|
|
*/ |
389
|
|
|
public function getRedirectstatus() |
390
|
|
|
{ |
391
|
|
|
return $this->redirectstatus; |
392
|
|
|
} |
393
|
|
|
|
394
|
|
|
/** |
395
|
|
|
* Set the redirect status |
396
|
|
|
* |
397
|
|
|
* @param int $redirectstatus Redirect status |
398
|
|
|
* @return Vhost Self reference |
399
|
|
|
*/ |
400
|
|
|
public function setRedirectstatus($redirectstatus) |
401
|
|
|
{ |
402
|
|
|
$this->redirectstatus = $redirectstatus; |
403
|
|
|
return $this; |
404
|
|
|
} |
405
|
|
|
} |
406
|
|
|
|