/
IpAccessControlEvent.php
218 lines (193 loc) · 5.01 KB
/
IpAccessControlEvent.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
<?php
namespace Concrete\Core\Entity\Permission;
use Concrete\Core\Entity\Site\Site;
use DateTime;
use Doctrine\ORM\Mapping as ORM;
use IPLib\Address\AddressInterface;
use IPLib\Factory;
/**
* Represent an IP Access Control Event.
*
* @ORM\Entity()
* @ORM\Table(
* name="IpAccessControlEvents",
* options={
* "comment": "List of IP Access Control Events"
* }
* )
*/
class IpAccessControlEvent
{
/**
* The IP Access Control Event identifier.
*
* @ORM\Column(name="iaceID", type="integer", nullable=false, options={"unsigned":true , "comment": "The IP Access Control Event identifier"})
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*
* @var int|null NULL when the record has not been saved yet
*/
protected $ipAccessControlEventID;
/**
* The associated IP Access Control Category.
*
* @ORM\ManyToOne(targetEntity="Concrete\Core\Entity\Permission\IpAccessControlCategory", inversedBy="events")
* @ORM\JoinColumn(name="iaceCategory", referencedColumnName="iaccID", nullable=false, onDelete="CASCADE")
*
* @var \Concrete\Core\Entity\Permission\IpAccessControlCategory
*/
protected $category;
/**
* The Site where this event occurred (if applicable).
*
* @ORM\ManyToOne(targetEntity="Concrete\Core\Entity\Site\Site")
* @ORM\JoinColumn(name="iaceSite", referencedColumnName="siteID", nullable=true, onDelete="CASCADE")
*
* @var \Concrete\Core\Entity\Site\Site|null
*/
protected $site;
/**
* The IP address associated to this event.
*
* @ORM\Column(name="iaceIp", type="string", length=40, nullable=false, options={"comment": "The IP address associated to this event"})
*
* @var string
*/
protected $ip;
/**
* The date/time when this event occurred.
*
* @ORM\Column(name="iaceDateTime", type="datetime", nullable=false, options={"comment": "The date/time when this event occurred"})
*
* @var \DateTime
*/
protected $dateTime;
/**
* the IP address associated to this event.
*
* @var \IPLib\Address\AddressInterface|null
*/
private $ipAddress;
/**
* Get the IP Access Control Event identifier.
*
* @return int|null returns NULL when the record has not been saved yet
*/
public function getIpAccessControlEventID()
{
return $this->ipAccessControlEventID;
}
/**
* 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 event occurred (if applicable).
*
* @return \Concrete\Core\Entity\Site\Site|null
*/
public function getSite()
{
return $this->site;
}
/**
* Set the Site where this event occurred (if applicable).
*
* @param \Concrete\Core\Entity\Site\Site|null $value
*
* @return $this
*/
public function setSite(Site $value = null)
{
$this->site = $value;
return $this;
}
/**
* Get the IP address associated to this event.
*
* @return \IPLib\Address\AddressInterface
*/
public function getIpAddress()
{
if ($this->ipAddress === null) {
$ip = (string) $this->getIp();
if ($ip !== '') {
$this->ipAddress = Factory::parseAddressString($ip);
}
}
return $this->ipAddress;
}
/**
* Set the IP address associated to this event.
*
* @param \IPLib\Address\AddressInterface $value
*
* @return $this
*/
public function setIpAddress(AddressInterface $value)
{
$this->setIp($value->getComparableString());
$this->ipAddress = $value;
return $this;
}
/**
* Get the date/time when this event occurred.
*
* @return \DateTime
*/
public function getDateTime()
{
return $this->dateTime;
}
/**
* Set the date/time when this event occurred.
*
* @param \DateTime $value
*
* @return $this
*/
public function setDateTime(DateTime $value)
{
$this->dateTime = $value;
return $this;
}
/**
* Get the IP address associated to this event.
*
* @return string
*/
protected function getIp()
{
return $this->ip;
}
/**
* Set the IP address associated to this event.
*
* @param string $value
*
* @return $this
*/
protected function setIp($value)
{
$this->ip = (string) $value;
$this->ipAddress = null;
return $this;
}
}