/
IpAccessControlRange.php
288 lines (255 loc) · 6.63 KB
/
IpAccessControlRange.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
<?php
namespace Concrete\Core\Entity\Permission;
use Concrete\Core\Entity\Site\Site;
use DateTime;
use Doctrine\ORM\Mapping as ORM;
use IPLib\Factory;
use IPLib\Range\RangeInterface;
/**
* Represent an IP Access Control Range.
*
* @ORM\Entity()
* @ORM\Table(
* name="IpAccessControlRanges",
* indexes={
* @ORM\Index(name="IPIntervalExpiration", columns={"iacrIpFrom", "iacrIpTo", "iacrExpiration"})
* },
* options={
* "comment": "List of IP Access Control Ranges"
* }
* )
*/
class IpAccessControlRange
{
/**
* The IP Access Control Range identifier.
*
* @ORM\Column(name="iacrID", type="integer", nullable=false, options={"unsigned":true , "comment": "The IP Access Control Range identifier"})
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*
* @var int|null NULL when the record has not been saved yet
*/
protected $ipAccessControlRangeID;
/**
* The associated IP Access Control Category.
*
* @ORM\ManyToOne(targetEntity="Concrete\Core\Entity\Permission\IpAccessControlCategory", inversedBy="ranges")
* @ORM\JoinColumn(name="iacrCategory", referencedColumnName="iaccID", nullable=false, onDelete="CASCADE")
*
* @var \Concrete\Core\Entity\Permission\IpAccessControlCategory
*/
protected $category;
/**
* The Site where this range is defined occurred (if applicable).
*
* @ORM\ManyToOne(targetEntity="Concrete\Core\Entity\Site\Site")
* @ORM\JoinColumn(name="iacrSite", referencedColumnName="siteID", nullable=true, onDelete="CASCADE")
*
* @var \Concrete\Core\Entity\Site\Site|null
*/
protected $site;
/**
* The initial IP address of the range.
*
* @ORM\Column(name="iacrIpFrom", type="string", length=40, nullable=false, options={"comment": "The initial IP address of the range"})
*
* @var string
*/
protected $ipFrom;
/**
* The final IP address of the range.
*
* @ORM\Column(name="iacrIpTo", type="string", length=40, nullable=false, options={"comment": "The final IP address of the range"})
*
* @var string
*/
protected $ipTo;
/**
* The type of this range.
*
* @ORM\Column(name="iacrType", type="integer", nullable=false, options={"unsigned": true, "comment": "The type of this range"})
*
* @var int
*/
protected $type;
/**
* The date/time when this range expires (NULL means no expiration).
*
* @ORM\Column(name="iacrExpiration", type="datetime", nullable=true, options={"comment": "The date/time when this range expires (NULL means no expiration)"})
*
* @var \DateTime|null
*/
protected $expiration;
/**
* The RangeInterface instance associated to this range.
*
* @var \IPLib\Range\RangeInterface|null
*/
private $ipRange;
/**
* Get the IP Access Control Range identifier.
*
* @return int|null returns NULL when the record has not been saved yet
*/
public function getIpAccessControlRangeID()
{
return $this->ipAccessControlRangeID;
}
/**
* Get the associated IP Access Control Category.
*
* @return \Concrete\Core\Entity\Permission\IpAccessControlCategory
*/
public function getCategory()
{
return $this->category;
}
/**
* Set the associated IP Access Control Category.
*
* @param \Concrete\Core\Entity\Permission\IpAccessControlCategory $value
*
* @return $this
*/
public function setCategory(IpAccessControlCategory $value)
{
$this->category = $value;
return $this;
}
/**
* Get the Site where this range is defined occurred (if applicable).
*
* @return \Concrete\Core\Entity\Site\Site|null
*/
public function getSite()
{
return $this->site;
}
/**
* @param \Concrete\Core\Entity\Site\Site|null $value
*
* @return $this
*/
public function setSite(Site $value = null)
{
$this->site = $value;
return $this;
}
/**
* Get the RangeInterface instance associated to this range.
*
* @return \IPLib\Range\RangeInterface
*/
public function getIpRange()
{
if ($this->ipRange === null) {
$ipFrom = (string) $this->getIpFrom();
if ($ipFrom !== '') {
$ipTo = (string) $this->getIpTo();
if ($ipTo !== '') {
$this->ipRange = Factory::getRangeFromBoundaries($ipFrom, $ipTo);
}
}
}
return $this->ipRange;
}
/**
* Set the RangeInterface instance associated to this range.
*
* @param \IPLib\Address\AddressInterface $value
*
* @return $this
*/
public function setIpRange(RangeInterface $value)
{
$this->setIpFrom($value->getComparableStartString());
$this->setIpTo($value->getComparableEndString());
$this->ipRange = $value;
return $this;
}
/**
* Get the type of this range.
*
* @return int
*/
public function getType()
{
return $this->type;
}
/**
* Set the type of this range.
*
* @param int $value
*
* @return $this
*/
public function setType($value)
{
$this->type = (int) $value;
return $this;
}
/**
* Get the date/time when this range expires (NULL means no expiration).
*
* @return \DateTime|null
*/
public function getExpiration()
{
return $this->expiration;
}
/**
* Set the date/time when this range expires (NULL means no expiration).
*
* @param \DateTime| $value
*
* @return $this
*/
public function setExpiration(DateTime $value = null)
{
$this->expiration = $value;
return $this;
}
/**
* Get the initial IP address of the range.
*
* @return string
*/
protected function getIpFrom()
{
return $this->ipFrom;
}
/**
* Set the initial IP address of the range.
*
* @param string $value
*
* @return $this
*/
protected function setIpFrom($value)
{
$this->ipFrom = (string) $value;
return $this;
}
/**
* Get the final IP address of the range.
*
* @return string
*/
protected function getIpTo()
{
return $this->ipTo;
}
/**
* Set the final IP address of the range.
*
* @param string $value
*
* @return $this
*/
protected function setIpTo($value)
{
$this->ipTo = (string) $value;
return $this;
}
}