|
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 integer |
|
20
|
|
|
* |
|
21
|
|
|
* @ORM\Column(name="id", type="integer") |
|
22
|
|
|
* @ORM\Id |
|
23
|
|
|
* @ORM\GeneratedValue(strategy="IDENTITY") |
|
24
|
|
|
*/ |
|
25
|
|
|
protected $id; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* @var string |
|
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 \DateTime |
|
50
|
|
|
* |
|
51
|
|
|
* @ORM\Column(name="time_created", type="datetime") |
|
52
|
|
|
*/ |
|
53
|
|
|
protected $timeCreated; |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* @var \DateTime |
|
57
|
|
|
* |
|
58
|
|
|
* @ORM\Column(name="time_updated", type="datetime") |
|
59
|
|
|
*/ |
|
60
|
|
|
protected $timeUpdated; |
|
61
|
|
|
|
|
62
|
|
|
/*** Id ***/ |
|
63
|
|
|
/** |
|
64
|
|
|
* @return integer |
|
65
|
|
|
*/ |
|
66
|
|
|
public function getId() |
|
67
|
|
|
{ |
|
68
|
|
|
return $this->id; |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* @param integer $id |
|
73
|
|
|
* |
|
74
|
|
|
* @return ErrorEntity |
|
75
|
|
|
*/ |
|
76
|
|
|
public function setId($id) |
|
77
|
|
|
{ |
|
78
|
|
|
$this->id = $id; |
|
79
|
|
|
|
|
80
|
|
|
return $this; |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/*** Code ***/ |
|
84
|
|
|
/** |
|
85
|
|
|
* @return integer |
|
86
|
|
|
*/ |
|
87
|
|
|
public function getCode() |
|
88
|
|
|
{ |
|
89
|
|
|
return $this->code; |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* @param integer $code |
|
94
|
|
|
* |
|
95
|
|
|
* @return ErrorEntity |
|
96
|
|
|
*/ |
|
97
|
|
|
public function setCode($code) |
|
98
|
|
|
{ |
|
99
|
|
|
$this->code = $code; |
|
|
|
|
|
|
100
|
|
|
|
|
101
|
|
|
return $this; |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
/*** Message ***/ |
|
105
|
|
|
/** |
|
106
|
|
|
* @return string |
|
107
|
|
|
*/ |
|
108
|
|
|
public function getMessage() |
|
109
|
|
|
{ |
|
110
|
|
|
return $this->message; |
|
111
|
|
|
} |
|
112
|
|
|
|
|
113
|
|
|
/** |
|
114
|
|
|
* @param string $message |
|
115
|
|
|
* |
|
116
|
|
|
* @return ErrorEntity |
|
117
|
|
|
*/ |
|
118
|
|
|
public function setMessage($message) |
|
119
|
|
|
{ |
|
120
|
|
|
$this->message = $message; |
|
121
|
|
|
|
|
122
|
|
|
return $this; |
|
123
|
|
|
} |
|
124
|
|
|
|
|
125
|
|
|
/*** Exception ***/ |
|
126
|
|
|
/** |
|
127
|
|
|
* @return string |
|
128
|
|
|
*/ |
|
129
|
|
|
public function getException() |
|
130
|
|
|
{ |
|
131
|
|
|
return $this->exception; |
|
132
|
|
|
} |
|
133
|
|
|
|
|
134
|
|
|
/** |
|
135
|
|
|
* @param string $exception |
|
136
|
|
|
* |
|
137
|
|
|
* @return ErrorEntity |
|
138
|
|
|
*/ |
|
139
|
|
|
public function setException($exception) |
|
140
|
|
|
{ |
|
141
|
|
|
$this->exception = $exception; |
|
142
|
|
|
|
|
143
|
|
|
return $this; |
|
144
|
|
|
} |
|
145
|
|
|
|
|
146
|
|
|
/*** Time created ***/ |
|
147
|
|
|
/** |
|
148
|
|
|
* @return \DateTime |
|
149
|
|
|
*/ |
|
150
|
|
|
public function getTimeCreated() |
|
151
|
|
|
{ |
|
152
|
|
|
return $this->timeCreated; |
|
153
|
|
|
} |
|
154
|
|
|
|
|
155
|
|
|
/** |
|
156
|
|
|
* @param \DateTime $timeCreated |
|
157
|
|
|
* |
|
158
|
|
|
* @return ErrorEntity |
|
159
|
|
|
*/ |
|
160
|
|
|
public function setTimeCreated(\DateTime $timeCreated) |
|
161
|
|
|
{ |
|
162
|
|
|
$this->timeCreated = $timeCreated; |
|
163
|
|
|
|
|
164
|
|
|
return $this; |
|
165
|
|
|
} |
|
166
|
|
|
|
|
167
|
|
|
/*** Time updated ***/ |
|
168
|
|
|
/** |
|
169
|
|
|
* @return \DateTime |
|
170
|
|
|
*/ |
|
171
|
|
|
public function getTimeUpdated() |
|
172
|
|
|
{ |
|
173
|
|
|
return $this->timeUpdated; |
|
174
|
|
|
} |
|
175
|
|
|
|
|
176
|
|
|
/** |
|
177
|
|
|
* @param \DateTime $timeUpdated |
|
178
|
|
|
* |
|
179
|
|
|
* @return ErrorEntity |
|
180
|
|
|
*/ |
|
181
|
|
|
public function setTimeUpdated(\DateTime $timeUpdated) |
|
182
|
|
|
{ |
|
183
|
|
|
$this->timeUpdated = $timeUpdated; |
|
184
|
|
|
|
|
185
|
|
|
return $this; |
|
186
|
|
|
} |
|
187
|
|
|
|
|
188
|
|
|
/** |
|
189
|
|
|
* @return array |
|
190
|
|
|
*/ |
|
191
|
|
|
public function toArray() |
|
192
|
|
|
{ |
|
193
|
|
|
return array( |
|
194
|
|
|
'id' => $this->getId(), |
|
195
|
|
|
'code' => $this->getCode(), |
|
196
|
|
|
'message' => $this->getMessage(), |
|
197
|
|
|
'time_created' => $this->getTimeCreated()->format(DATE_ATOM), |
|
198
|
|
|
'time_updated' => $this->getTimeUpdated()->format(DATE_ATOM), |
|
199
|
|
|
); |
|
200
|
|
|
} |
|
201
|
|
|
|
|
202
|
|
|
/** |
|
203
|
|
|
* @return string |
|
204
|
|
|
*/ |
|
205
|
|
|
public function __toString() |
|
206
|
|
|
{ |
|
207
|
|
|
return $this->getMessage(); |
|
208
|
|
|
} |
|
209
|
|
|
|
|
210
|
|
|
/** |
|
211
|
|
|
* @ORM\PreUpdate |
|
212
|
|
|
*/ |
|
213
|
|
|
public function preUpdate() |
|
214
|
|
|
{ |
|
215
|
|
|
$this->setTimeUpdated(new \DateTime('now')); |
|
216
|
|
|
} |
|
217
|
|
|
|
|
218
|
|
|
/** |
|
219
|
|
|
* @ORM\PrePersist |
|
220
|
|
|
*/ |
|
221
|
|
|
public function prePersist() |
|
222
|
|
|
{ |
|
223
|
|
|
$this->setTimeUpdated(new \DateTime('now')); |
|
224
|
|
|
$this->setTimeCreated(new \DateTime('now')); |
|
225
|
|
|
} |
|
226
|
|
|
} |
|
227
|
|
|
|
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.