1
|
|
|
<?php |
2
|
|
|
namespace PlaygroundGame\Entity; |
3
|
|
|
|
4
|
|
|
use Doctrine\ORM\Mapping as ORM; |
5
|
|
|
use Doctrine\ORM\Mapping\HasLifecycleCallbacks; |
6
|
|
|
use Doctrine\ORM\Mapping\PrePersist; |
7
|
|
|
use Doctrine\ORM\Mapping\PreUpdate; |
8
|
|
|
use Zend\InputFilter\InputFilter; |
9
|
|
|
use Zend\InputFilter\InputFilterAwareInterface; |
10
|
|
|
use Zend\InputFilter\InputFilterInterface; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* @ORM\Entity @HasLifecycleCallbacks |
14
|
|
|
* @ORM\Table(name="game_postvote_comment") |
15
|
|
|
*/ |
16
|
|
View Code Duplication |
class PostVoteComment implements InputFilterAwareInterface |
|
|
|
|
17
|
|
|
{ |
18
|
|
|
protected $inputFilter; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @ORM\Id |
22
|
|
|
* @ORM\Column(type="integer"); |
23
|
|
|
* @ORM\GeneratedValue(strategy="AUTO") |
24
|
|
|
*/ |
25
|
|
|
protected $id; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @ORM\ManyToOne(targetEntity="PostVotePost", inversedBy="comments") |
29
|
|
|
* @ORM\JoinColumn(name="post_id", referencedColumnName="id", onDelete="CASCADE") |
30
|
|
|
**/ |
31
|
|
|
protected $post; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @ORM\ManyToOne(targetEntity="PostVote") |
35
|
|
|
**/ |
36
|
|
|
protected $postvote; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @ORM\ManyToOne(targetEntity="PlaygroundUser\Entity\User") |
40
|
|
|
* @ORM\JoinColumn(name="user_id", referencedColumnName="user_id") |
41
|
|
|
**/ |
42
|
|
|
protected $user; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @ORM\Column(type="text", nullable=true) |
46
|
|
|
*/ |
47
|
|
|
protected $ip; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @ORM\Column(type="text", nullable=true) |
51
|
|
|
*/ |
52
|
|
|
protected $message; |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @ORM\Column(name="created_at", type="datetime") |
56
|
|
|
*/ |
57
|
|
|
protected $createdAt; |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @ORM\Column(name="updated_at", type="datetime") |
61
|
|
|
*/ |
62
|
|
|
protected $updatedAt; |
63
|
|
|
|
64
|
|
|
/** @PrePersist */ |
65
|
|
|
public function createChrono() |
66
|
|
|
{ |
67
|
|
|
$this->createdAt = new \DateTime("now"); |
68
|
|
|
$this->updatedAt = new \DateTime("now"); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** @PreUpdate */ |
72
|
|
|
public function updateChrono() |
73
|
|
|
{ |
74
|
|
|
$this->updatedAt = new \DateTime("now"); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @return the unknown_type |
79
|
|
|
*/ |
80
|
|
|
public function getId() |
81
|
|
|
{ |
82
|
|
|
return $this->id; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* @param unknown_type $id |
87
|
|
|
*/ |
88
|
|
|
public function setId($id) |
89
|
|
|
{ |
90
|
|
|
$this->id = $id; |
91
|
|
|
|
92
|
|
|
return $this; |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* @return string unknown_type |
97
|
|
|
*/ |
98
|
|
|
public function getIp() |
99
|
|
|
{ |
100
|
|
|
return $this->ip; |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* @param string $ip |
105
|
|
|
*/ |
106
|
|
|
public function setIp($ip) |
107
|
|
|
{ |
108
|
|
|
$this->ip = $ip; |
109
|
|
|
|
110
|
|
|
return $this; |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* @return the unknown_type |
115
|
|
|
*/ |
116
|
|
|
public function getUser() |
117
|
|
|
{ |
118
|
|
|
return $this->user; |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* @param unknown_type $user |
123
|
|
|
*/ |
124
|
|
|
public function setUser($user) |
125
|
|
|
{ |
126
|
|
|
$this->user = $user; |
127
|
|
|
|
128
|
|
|
return $this; |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
/** |
132
|
|
|
* @return the unknown_type |
133
|
|
|
*/ |
134
|
|
|
public function getPost() |
135
|
|
|
{ |
136
|
|
|
return $this->post; |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
/** |
140
|
|
|
* @param unknown_type $post |
141
|
|
|
*/ |
142
|
|
|
public function setPost($post) |
143
|
|
|
{ |
144
|
|
|
// Check that there is no drawback using the cascading update from PostVoteEntry |
145
|
|
|
$post->addComment($this); |
146
|
|
|
$this->post = $post; |
147
|
|
|
|
148
|
|
|
return $this; |
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
/** |
152
|
|
|
* @return the unknown_type |
153
|
|
|
*/ |
154
|
|
|
public function getPostvote() |
155
|
|
|
{ |
156
|
|
|
return $this->postvote; |
157
|
|
|
} |
158
|
|
|
|
159
|
|
|
/** |
160
|
|
|
* @param unknown_type $postvote |
161
|
|
|
*/ |
162
|
|
|
public function setPostvote($postvote) |
163
|
|
|
{ |
164
|
|
|
|
165
|
|
|
$this->postvote = $postvote; |
166
|
|
|
|
167
|
|
|
return $this; |
168
|
|
|
} |
169
|
|
|
|
170
|
|
|
/** |
171
|
|
|
* @return the unknown_type |
172
|
|
|
*/ |
173
|
|
|
public function getMessage() |
174
|
|
|
{ |
175
|
|
|
return $this->message; |
176
|
|
|
} |
177
|
|
|
|
178
|
|
|
/** |
179
|
|
|
* @param unknown_type $message |
180
|
|
|
*/ |
181
|
|
|
public function setMessage($message) |
182
|
|
|
{ |
183
|
|
|
$this->message = $message; |
184
|
|
|
|
185
|
|
|
return $this; |
186
|
|
|
} |
187
|
|
|
|
188
|
|
|
/** |
189
|
|
|
* @return the unknown_type |
190
|
|
|
*/ |
191
|
|
|
public function getCreatedAt() |
192
|
|
|
{ |
193
|
|
|
return $this->createdAt; |
194
|
|
|
} |
195
|
|
|
|
196
|
|
|
/** |
197
|
|
|
* @param unknown_type $createdAt |
198
|
|
|
*/ |
199
|
|
|
public function setCreatedAt($createdAt) |
200
|
|
|
{ |
201
|
|
|
$this->createdAt = $createdAt; |
202
|
|
|
|
203
|
|
|
return $this; |
204
|
|
|
} |
205
|
|
|
|
206
|
|
|
/** |
207
|
|
|
* @return the unknown_type |
208
|
|
|
*/ |
209
|
|
|
public function getUpdatedAt() |
210
|
|
|
{ |
211
|
|
|
return $this->updatedAt; |
212
|
|
|
} |
213
|
|
|
|
214
|
|
|
/** |
215
|
|
|
* @param unknown_type $updatedAt |
216
|
|
|
*/ |
217
|
|
|
public function setUpdatedAt($updatedAt) |
218
|
|
|
{ |
219
|
|
|
$this->updatedAt = $updatedAt; |
220
|
|
|
|
221
|
|
|
return $this; |
222
|
|
|
} |
223
|
|
|
|
224
|
|
|
/** |
225
|
|
|
* Convert the object to an array. |
226
|
|
|
* |
227
|
|
|
* @return array |
228
|
|
|
*/ |
229
|
|
|
public function getArrayCopy() |
230
|
|
|
{ |
231
|
|
|
$obj_vars = get_object_vars($this); |
232
|
|
|
|
233
|
|
|
return $obj_vars; |
234
|
|
|
} |
235
|
|
|
|
236
|
|
|
/** |
237
|
|
|
* Populate from an array. |
238
|
|
|
* |
239
|
|
|
* @param array $data |
240
|
|
|
*/ |
241
|
|
|
public function populate($data = array()) |
|
|
|
|
242
|
|
|
{ |
243
|
|
|
} |
244
|
|
|
|
245
|
|
|
public function setInputFilter(InputFilterInterface $inputFilter) |
246
|
|
|
{ |
247
|
|
|
throw new \Exception("Not used"); |
248
|
|
|
} |
249
|
|
|
|
250
|
|
|
public function getInputFilter() |
251
|
|
|
{ |
252
|
|
|
if (!$this->inputFilter) { |
253
|
|
|
$inputFilter = new InputFilter(); |
254
|
|
|
|
255
|
|
|
$this->inputFilter = $inputFilter; |
256
|
|
|
} |
257
|
|
|
|
258
|
|
|
return $this->inputFilter; |
259
|
|
|
} |
260
|
|
|
} |
261
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.