|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* admin |
|
5
|
|
|
* |
|
6
|
|
|
* @category Tollwerk |
|
7
|
|
|
* @package Tollwerk\Admin |
|
8
|
|
|
* @subpackage Tollwerk\Admin\Infrastructure\Model |
|
9
|
|
|
* @author Joschi Kuphal <[email protected]> / @jkphl |
|
10
|
|
|
* @copyright Copyright © 2018 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 © 2018 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
|
|
|
/** |
|
40
|
|
|
* Domain model |
|
41
|
|
|
* |
|
42
|
|
|
* @package Tollwerk\Admin |
|
43
|
|
|
* @subpackage Tollwerk\Admin\Infrastructure |
|
44
|
|
|
* @Entity |
|
45
|
|
|
* @Table(name="domain",uniqueConstraints={@UniqueConstraint(name="primary_idx", columns={"vhost_id", "primarydomain"})}) |
|
46
|
|
|
*/ |
|
47
|
|
|
class Domain |
|
48
|
|
|
{ |
|
49
|
|
|
/** |
|
50
|
|
|
* Domain ID |
|
51
|
|
|
* |
|
52
|
|
|
* @var integer |
|
53
|
|
|
* @Id @Column(type="integer") |
|
54
|
|
|
* @GeneratedValue |
|
55
|
|
|
*/ |
|
56
|
|
|
protected $id; |
|
57
|
|
|
/** |
|
58
|
|
|
* Active |
|
59
|
|
|
* |
|
60
|
|
|
* @var boolean |
|
61
|
|
|
* @Column(type="boolean") |
|
62
|
|
|
*/ |
|
63
|
|
|
protected $active; |
|
64
|
|
|
/** |
|
65
|
|
|
* Domain name |
|
66
|
|
|
* |
|
67
|
|
|
* @var string |
|
68
|
|
|
* @Column(length=128,unique=true) |
|
69
|
|
|
*/ |
|
70
|
|
|
protected $name; |
|
71
|
|
|
/** |
|
72
|
|
|
* Account this domain is belonging to |
|
73
|
|
|
* |
|
74
|
|
|
* @var Account |
|
75
|
|
|
* @ManyToOne(targetEntity="Tollwerk\Admin\Infrastructure\Model\Account", inversedBy="domains") |
|
76
|
|
|
* @JoinColumn(name="account_id", referencedColumnName="id", onDelete="CASCADE") |
|
77
|
|
|
*/ |
|
78
|
|
|
protected $account; |
|
79
|
|
|
/** |
|
80
|
|
|
* Virtual host this domain is belonging to |
|
81
|
|
|
* |
|
82
|
|
|
* @var Vhost|null |
|
83
|
|
|
* @ManyToOne(targetEntity="Tollwerk\Admin\Infrastructure\Model\Vhost", inversedBy="domains") |
|
84
|
|
|
* @JoinColumn(name="vhost_id", referencedColumnName="id", onDelete="SET NULL") |
|
85
|
|
|
*/ |
|
86
|
|
|
protected $vhost; |
|
87
|
|
|
/** |
|
88
|
|
|
* Primary domain |
|
89
|
|
|
* |
|
90
|
|
|
* @var boolean |
|
91
|
|
|
* @Column(type="boolean", nullable=true) |
|
92
|
|
|
*/ |
|
93
|
|
|
protected $primarydomain; |
|
94
|
|
|
/** |
|
95
|
|
|
* Add the wildcard subdomain |
|
96
|
|
|
* |
|
97
|
|
|
* @var boolean |
|
98
|
|
|
* @Column(type="boolean") |
|
99
|
|
|
*/ |
|
100
|
|
|
protected $wildcard; |
|
101
|
|
|
|
|
102
|
|
|
/** |
|
103
|
|
|
* Return the domain ID |
|
104
|
|
|
* |
|
105
|
|
|
* @return int Domain ID |
|
106
|
|
|
*/ |
|
107
|
|
|
public function getId() |
|
108
|
|
|
{ |
|
109
|
|
|
return $this->id; |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
/** |
|
113
|
|
|
* Set the domain ID |
|
114
|
|
|
* |
|
115
|
|
|
* @param int $id Domain ID |
|
116
|
|
|
* @return Domain |
|
117
|
|
|
*/ |
|
118
|
|
|
public function setId($id) |
|
119
|
|
|
{ |
|
120
|
|
|
$this->id = $id; |
|
121
|
|
|
return $this; |
|
122
|
|
|
} |
|
123
|
|
|
|
|
124
|
|
|
/** |
|
125
|
|
|
* Return the domain name |
|
126
|
|
|
* |
|
127
|
|
|
* @return string Domain name |
|
128
|
|
|
*/ |
|
129
|
|
|
public function getName() |
|
130
|
|
|
{ |
|
131
|
|
|
return $this->name; |
|
132
|
|
|
} |
|
133
|
|
|
|
|
134
|
|
|
/** |
|
135
|
|
|
* Set the domain name |
|
136
|
|
|
* |
|
137
|
|
|
* @param string $name Domain name |
|
138
|
|
|
* @return Domain |
|
139
|
|
|
*/ |
|
140
|
|
|
public function setName($name) |
|
141
|
|
|
{ |
|
142
|
|
|
$this->name = $name; |
|
143
|
|
|
return $this; |
|
144
|
|
|
} |
|
145
|
|
|
|
|
146
|
|
|
/** |
|
147
|
|
|
* Set whether this is an active domain |
|
148
|
|
|
* |
|
149
|
|
|
* @param boolean $active Active domain |
|
150
|
|
|
* @return Domain |
|
151
|
|
|
*/ |
|
152
|
|
|
public function setActive($active) |
|
153
|
|
|
{ |
|
154
|
|
|
$this->active = $active; |
|
155
|
|
|
return $this; |
|
156
|
|
|
} |
|
157
|
|
|
|
|
158
|
|
|
/** |
|
159
|
|
|
* Return whether the domain is ative |
|
160
|
|
|
* |
|
161
|
|
|
* @return boolean Active domain |
|
162
|
|
|
*/ |
|
163
|
|
|
public function isActive() |
|
164
|
|
|
{ |
|
165
|
|
|
return $this->active; |
|
166
|
|
|
} |
|
167
|
|
|
|
|
168
|
|
|
/** |
|
169
|
|
|
* Return the account this domain is belonging to |
|
170
|
|
|
* |
|
171
|
|
|
* @return Account Account |
|
172
|
|
|
*/ |
|
173
|
|
|
public function getAccount() |
|
174
|
|
|
{ |
|
175
|
|
|
return $this->account; |
|
176
|
|
|
} |
|
177
|
|
|
|
|
178
|
|
|
/** |
|
179
|
|
|
* Set the account this domain is belonging tp |
|
180
|
|
|
* |
|
181
|
|
|
* @param Account $account Account |
|
182
|
|
|
* @return Domain Self reference |
|
183
|
|
|
*/ |
|
184
|
|
|
public function setAccount($account) |
|
185
|
|
|
{ |
|
186
|
|
|
$this->account = $account; |
|
187
|
|
|
return $this; |
|
188
|
|
|
} |
|
189
|
|
|
|
|
190
|
|
|
/** |
|
191
|
|
|
* Return the virtual host this domain is belonging to |
|
192
|
|
|
* |
|
193
|
|
|
* @return Vhost Virtual host this domain is belonging to |
|
194
|
|
|
*/ |
|
195
|
|
|
public function getVhost() |
|
196
|
|
|
{ |
|
197
|
|
|
return $this->vhost; |
|
198
|
|
|
} |
|
199
|
|
|
|
|
200
|
|
|
/** |
|
201
|
|
|
* Set the virtual host this domain is belonging to |
|
202
|
|
|
* |
|
203
|
|
|
* @param Vhost $vhost Virtual host this domain is belonging to |
|
204
|
|
|
* @return Domain Self reference |
|
205
|
|
|
*/ |
|
206
|
|
|
public function setVhost($vhost = null) |
|
207
|
|
|
{ |
|
208
|
|
|
$this->vhost = $vhost; |
|
209
|
|
|
return $this; |
|
210
|
|
|
} |
|
211
|
|
|
|
|
212
|
|
|
/** |
|
213
|
|
|
* Return whether the wildcard subdomain option is enabled |
|
214
|
|
|
* |
|
215
|
|
|
* @return boolean Wildcard subdomain enabled |
|
216
|
|
|
*/ |
|
217
|
|
|
public function isWildcard() |
|
218
|
|
|
{ |
|
219
|
|
|
return $this->wildcard; |
|
220
|
|
|
} |
|
221
|
|
|
|
|
222
|
|
|
/** |
|
223
|
|
|
* Set whether the wildcard subdomain option is enabled |
|
224
|
|
|
* |
|
225
|
|
|
* @param boolean $wildcard Enable the wildcard subdomain |
|
226
|
|
|
* @return Domain Self reference |
|
227
|
|
|
*/ |
|
228
|
|
|
public function setWildcard($wildcard) |
|
229
|
|
|
{ |
|
230
|
|
|
$this->wildcard = $wildcard; |
|
231
|
|
|
return $this; |
|
232
|
|
|
} |
|
233
|
|
|
|
|
234
|
|
|
/** |
|
235
|
|
|
* Return whether this is the primary domain of the associated virtual host |
|
236
|
|
|
* |
|
237
|
|
|
* @return boolean Primary domain |
|
238
|
|
|
*/ |
|
239
|
|
|
public function isPrimarydomain() |
|
240
|
|
|
{ |
|
241
|
|
|
return $this->primarydomain; |
|
242
|
|
|
} |
|
243
|
|
|
|
|
244
|
|
|
/** |
|
245
|
|
|
* Set whether this is the primary domain of the associated virtual host |
|
246
|
|
|
* |
|
247
|
|
|
* @param boolean $primarydomain Primary domain |
|
248
|
|
|
* @return Domain Self reference |
|
249
|
|
|
*/ |
|
250
|
|
|
public function setPrimarydomain($primarydomain) |
|
251
|
|
|
{ |
|
252
|
|
|
$this->primarydomain = $primarydomain ?: null; |
|
253
|
|
|
return $this; |
|
254
|
|
|
} |
|
255
|
|
|
} |
|
256
|
|
|
|