1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @author Gerard van Helden <[email protected]> |
4
|
|
|
* @copyright Zicht Online <http://zicht.nl> |
5
|
|
|
*/ |
6
|
|
|
namespace Zicht\Bundle\UrlBundle\Entity; |
7
|
|
|
|
8
|
|
|
use Doctrine\ORM\Mapping as ORM; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Log entries |
12
|
|
|
* |
13
|
|
|
* @ORM\Entity |
14
|
|
|
* @ORM\Table(name="url_error_log") |
15
|
|
|
*/ |
16
|
|
|
class ErrorLog |
17
|
|
|
{ |
18
|
|
|
/** |
19
|
|
|
* @ORM\GeneratedValue(strategy="AUTO") |
20
|
|
|
* @ORM\Id |
21
|
|
|
* @ORM\Column(type="integer") |
22
|
|
|
*/ |
23
|
|
|
protected $id; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @ORM\Column(type="integer", nullable=true) |
27
|
|
|
*/ |
28
|
|
|
protected $status; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @ORM\Column(type="string", length=1024, nullable=true) |
32
|
|
|
*/ |
33
|
|
|
protected $url; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @ORM\Column(type="string", length=255) |
37
|
|
|
*/ |
38
|
|
|
protected $ip; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @ORM\Column(type="string", length=1024) |
42
|
|
|
*/ |
43
|
|
|
protected $ua; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @ORM\Column(type="string", nullable=true) |
47
|
|
|
*/ |
48
|
|
|
protected $message; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @ORM\Column(type="string", nullable=true) |
52
|
|
|
*/ |
53
|
|
|
protected $referer; |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @ORM\Column(type="datetime", nullable=true) |
57
|
|
|
*/ |
58
|
|
|
protected $date_created; |
59
|
|
|
|
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Create the log entry |
63
|
|
|
* |
64
|
|
|
* @param string $message |
65
|
|
|
* @param \DateTime $date_created |
66
|
|
|
* @param string $referer |
67
|
|
|
* @param string $ua |
68
|
|
|
* @param string $ip |
69
|
|
|
* @param string $url |
70
|
|
|
*/ |
71
|
3 |
|
public function __construct($message, $date_created, $referer, $ua, $ip, $url) |
72
|
|
|
{ |
73
|
|
|
$this |
74
|
3 |
|
->setMessage($message) |
75
|
3 |
|
->setDateCreated($date_created) |
76
|
3 |
|
->setReferer($referer) |
77
|
3 |
|
->setUa($ua) |
78
|
3 |
|
->setIp($ip) |
79
|
3 |
|
->setUrl($url); |
80
|
3 |
|
} |
81
|
|
|
|
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @return mixed |
85
|
|
|
*/ |
86
|
1 |
|
public function getId() |
87
|
|
|
{ |
88
|
1 |
|
return $this->id; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* @return string |
94
|
|
|
*/ |
95
|
1 |
|
public function __toString() |
96
|
|
|
{ |
97
|
1 |
|
return (string)$this->message |
98
|
1 |
|
. ' @ ' . (string)($this->date_created ? $this->date_created->format('YmdHis') : ''); |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* @param \DateTime $date_created |
103
|
|
|
* @return ErrorLog |
104
|
|
|
*/ |
105
|
3 |
|
public function setDateCreated($date_created) |
106
|
|
|
{ |
107
|
3 |
|
$this->date_created = $date_created; |
108
|
3 |
|
return $this; |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* @return mixed |
113
|
|
|
*/ |
114
|
1 |
|
public function getDateCreated() |
115
|
|
|
{ |
116
|
1 |
|
return $this->date_created; |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* @param string $ip |
121
|
|
|
* @return self |
122
|
|
|
*/ |
123
|
3 |
|
public function setIp($ip) |
124
|
|
|
{ |
125
|
3 |
|
$this->ip = $ip; |
126
|
3 |
|
return $this; |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* @return mixed |
131
|
|
|
*/ |
132
|
2 |
|
public function getIp() |
133
|
|
|
{ |
134
|
2 |
|
return $this->ip; |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
/** |
138
|
|
|
* @param string $message |
139
|
|
|
* @return self |
140
|
|
|
*/ |
141
|
3 |
|
public function setMessage($message) |
142
|
|
|
{ |
143
|
3 |
|
$this->message = $message; |
144
|
3 |
|
return $this; |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
/** |
148
|
|
|
* @return mixed |
149
|
|
|
*/ |
150
|
3 |
|
public function getMessage() |
151
|
|
|
{ |
152
|
3 |
|
return $this->message; |
153
|
|
|
} |
154
|
|
|
|
155
|
|
|
/** |
156
|
|
|
* @param string $referer |
157
|
|
|
* @return self |
158
|
|
|
*/ |
159
|
3 |
|
public function setReferer($referer) |
160
|
|
|
{ |
161
|
3 |
|
$this->referer = $referer; |
162
|
3 |
|
return $this; |
163
|
|
|
} |
164
|
|
|
|
165
|
|
|
/** |
166
|
|
|
* @return mixed |
167
|
|
|
*/ |
168
|
2 |
|
public function getReferer() |
169
|
|
|
{ |
170
|
2 |
|
return $this->referer; |
171
|
|
|
} |
172
|
|
|
|
173
|
|
|
/** |
174
|
|
|
* @param int $status |
175
|
|
|
* @return self |
176
|
|
|
*/ |
177
|
2 |
|
public function setStatus($status) |
178
|
|
|
{ |
179
|
2 |
|
$this->status = $status; |
180
|
2 |
|
return $this; |
181
|
|
|
} |
182
|
|
|
|
183
|
|
|
/** |
184
|
|
|
* @return mixed |
185
|
|
|
*/ |
186
|
1 |
|
public function getStatus() |
187
|
|
|
{ |
188
|
1 |
|
return $this->status; |
189
|
|
|
} |
190
|
|
|
|
191
|
|
|
/** |
192
|
|
|
* @param string $ua |
193
|
|
|
* @return self |
194
|
|
|
*/ |
195
|
3 |
|
public function setUa($ua) |
196
|
|
|
{ |
197
|
3 |
|
$this->ua = $ua; |
198
|
3 |
|
return $this; |
199
|
|
|
} |
200
|
|
|
|
201
|
|
|
/** |
202
|
|
|
* @return mixed |
203
|
|
|
*/ |
204
|
1 |
|
public function getUa() |
205
|
|
|
{ |
206
|
1 |
|
return $this->ua; |
207
|
|
|
} |
208
|
|
|
|
209
|
|
|
/** |
210
|
|
|
* @param string $url |
211
|
|
|
* @return self |
212
|
|
|
*/ |
213
|
3 |
|
public function setUrl($url) |
214
|
|
|
{ |
215
|
3 |
|
$this->url = $url; |
216
|
3 |
|
return $this; |
217
|
|
|
} |
218
|
|
|
|
219
|
|
|
/** |
220
|
|
|
* @return mixed |
221
|
|
|
*/ |
222
|
1 |
|
public function getUrl() |
223
|
|
|
{ |
224
|
1 |
|
return $this->url; |
225
|
|
|
} |
226
|
|
|
} |
227
|
|
|
|