1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Application\Entity; |
4
|
|
|
|
5
|
|
|
use Doctrine\ORM\Mapping as ORM; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Error Entity. |
9
|
|
|
* |
10
|
|
|
* @ORM\Table(name="errors") |
11
|
|
|
* @ORM\Entity(repositoryClass="Application\Repository\ErrorRepository") |
12
|
|
|
* @ORM\HasLifecycleCallbacks() |
13
|
|
|
* |
14
|
|
|
* @author Borut Balažek <[email protected]> |
15
|
|
|
*/ |
16
|
|
|
class ErrorEntity extends AbstractImageUpload |
17
|
|
|
{ |
18
|
|
|
/** |
19
|
|
|
* @var int |
20
|
|
|
* |
21
|
|
|
* @ORM\Column(name="id", type="integer") |
22
|
|
|
* @ORM\Id |
23
|
|
|
* @ORM\GeneratedValue(strategy="IDENTITY") |
24
|
|
|
*/ |
25
|
|
|
protected $id; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @var int |
29
|
|
|
* |
30
|
|
|
* @ORM\Column(name="code", type="integer") |
31
|
|
|
*/ |
32
|
|
|
protected $code; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @var string |
36
|
|
|
* |
37
|
|
|
* @ORM\Column(name="message", type="text", nullable=true) |
38
|
|
|
*/ |
39
|
|
|
protected $message; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @var string |
43
|
|
|
* |
44
|
|
|
* @ORM\Column(name="exception", type="text", nullable=true) |
45
|
|
|
*/ |
46
|
|
|
protected $exception; |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @var string |
50
|
|
|
* |
51
|
|
|
* @ORM\Column(name="data", type="text", nullable=true) |
52
|
|
|
*/ |
53
|
|
|
protected $data; |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @var \DateTime |
57
|
|
|
* |
58
|
|
|
* @ORM\Column(name="time_created", type="datetime") |
59
|
|
|
*/ |
60
|
|
|
protected $timeCreated; |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @var \DateTime |
64
|
|
|
* |
65
|
|
|
* @ORM\Column(name="time_updated", type="datetime") |
66
|
|
|
*/ |
67
|
|
|
protected $timeUpdated; |
68
|
|
|
|
69
|
|
|
/*** Id ***/ |
70
|
|
|
/** |
71
|
|
|
* @return int |
72
|
|
|
*/ |
73
|
|
|
public function getId() |
74
|
|
|
{ |
75
|
|
|
return $this->id; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* @param int $id |
80
|
|
|
* |
81
|
|
|
* @return ErrorEntity |
82
|
|
|
*/ |
83
|
|
|
public function setId($id) |
84
|
|
|
{ |
85
|
|
|
$this->id = $id; |
86
|
|
|
|
87
|
|
|
return $this; |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/*** Code ***/ |
91
|
|
|
/** |
92
|
|
|
* @return int |
93
|
|
|
*/ |
94
|
|
|
public function getCode() |
95
|
|
|
{ |
96
|
|
|
return $this->code; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* @param int $code |
101
|
|
|
* |
102
|
|
|
* @return ErrorEntity |
103
|
|
|
*/ |
104
|
|
|
public function setCode($code) |
105
|
|
|
{ |
106
|
|
|
$this->code = $code; |
107
|
|
|
|
108
|
|
|
return $this; |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
/*** Message ***/ |
112
|
|
|
/** |
113
|
|
|
* @return string |
114
|
|
|
*/ |
115
|
|
|
public function getMessage() |
116
|
|
|
{ |
117
|
|
|
return $this->message; |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* @param string $message |
122
|
|
|
* |
123
|
|
|
* @return ErrorEntity |
124
|
|
|
*/ |
125
|
|
|
public function setMessage($message) |
126
|
|
|
{ |
127
|
|
|
$this->message = $message; |
128
|
|
|
|
129
|
|
|
return $this; |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
/*** Exception ***/ |
133
|
|
|
/** |
134
|
|
|
* @return string |
135
|
|
|
*/ |
136
|
|
|
public function getException() |
137
|
|
|
{ |
138
|
|
|
return $this->exception; |
139
|
|
|
} |
140
|
|
|
|
141
|
|
|
/** |
142
|
|
|
* @param string $exception |
143
|
|
|
* |
144
|
|
|
* @return ErrorEntity |
145
|
|
|
*/ |
146
|
|
|
public function setException($exception) |
147
|
|
|
{ |
148
|
|
|
$this->exception = $exception; |
149
|
|
|
|
150
|
|
|
return $this; |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
/*** Data ***/ |
154
|
|
|
/** |
155
|
|
|
* @return string |
156
|
|
|
*/ |
157
|
|
|
public function getData() |
158
|
|
|
{ |
159
|
|
|
return $this->data; |
160
|
|
|
} |
161
|
|
|
|
162
|
|
|
/** |
163
|
|
|
* @param string $data |
164
|
|
|
* |
165
|
|
|
* @return ErrorEntity |
166
|
|
|
*/ |
167
|
|
|
public function setData($data) |
168
|
|
|
{ |
169
|
|
|
$this->data = $data; |
170
|
|
|
|
171
|
|
|
return $this; |
172
|
|
|
} |
173
|
|
|
|
174
|
|
|
/*** Time created ***/ |
175
|
|
|
/** |
176
|
|
|
* @return \DateTime |
177
|
|
|
*/ |
178
|
|
|
public function getTimeCreated() |
179
|
|
|
{ |
180
|
|
|
return $this->timeCreated; |
181
|
|
|
} |
182
|
|
|
|
183
|
|
|
/** |
184
|
|
|
* @param \DateTime $timeCreated |
185
|
|
|
* |
186
|
|
|
* @return ErrorEntity |
187
|
|
|
*/ |
188
|
|
|
public function setTimeCreated(\DateTime $timeCreated) |
189
|
|
|
{ |
190
|
|
|
$this->timeCreated = $timeCreated; |
191
|
|
|
|
192
|
|
|
return $this; |
193
|
|
|
} |
194
|
|
|
|
195
|
|
|
/*** Time updated ***/ |
196
|
|
|
/** |
197
|
|
|
* @return \DateTime |
198
|
|
|
*/ |
199
|
|
|
public function getTimeUpdated() |
200
|
|
|
{ |
201
|
|
|
return $this->timeUpdated; |
202
|
|
|
} |
203
|
|
|
|
204
|
|
|
/** |
205
|
|
|
* @param \DateTime $timeUpdated |
206
|
|
|
* |
207
|
|
|
* @return ErrorEntity |
208
|
|
|
*/ |
209
|
|
|
public function setTimeUpdated(\DateTime $timeUpdated) |
210
|
|
|
{ |
211
|
|
|
$this->timeUpdated = $timeUpdated; |
212
|
|
|
|
213
|
|
|
return $this; |
214
|
|
|
} |
215
|
|
|
|
216
|
|
|
/** |
217
|
|
|
* @return array |
218
|
|
|
*/ |
219
|
|
|
public function toArray() |
220
|
|
|
{ |
221
|
|
|
return array( |
222
|
|
|
'id' => $this->getId(), |
223
|
|
|
'code' => $this->getCode(), |
224
|
|
|
'message' => $this->getMessage(), |
225
|
|
|
'time_created' => $this->getTimeCreated()->format(DATE_ATOM), |
226
|
|
|
'time_updated' => $this->getTimeUpdated()->format(DATE_ATOM), |
227
|
|
|
); |
228
|
|
|
} |
229
|
|
|
|
230
|
|
|
/** |
231
|
|
|
* @return string |
232
|
|
|
*/ |
233
|
|
|
public function __toString() |
234
|
|
|
{ |
235
|
|
|
return $this->getMessage(); |
236
|
|
|
} |
237
|
|
|
|
238
|
|
|
/** |
239
|
|
|
* @ORM\PreUpdate |
240
|
|
|
*/ |
241
|
|
|
public function preUpdate() |
242
|
|
|
{ |
243
|
|
|
$this->setTimeUpdated(new \DateTime('now')); |
244
|
|
|
} |
245
|
|
|
|
246
|
|
|
/** |
247
|
|
|
* @ORM\PrePersist |
248
|
|
|
*/ |
249
|
|
|
public function prePersist() |
250
|
|
|
{ |
251
|
|
|
$this->setTimeUpdated(new \DateTime('now')); |
252
|
|
|
$this->setTimeCreated(new \DateTime('now')); |
253
|
|
|
} |
254
|
|
|
} |
255
|
|
|
|