1
|
|
|
<?php |
2
|
|
|
namespace PlaygroundGame\Entity; |
3
|
|
|
|
4
|
|
|
use PlaygroundGame\Entity\Game; |
5
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
6
|
|
|
use Gedmo\Mapping\Annotation as Gedmo; |
7
|
|
|
use Gedmo\Translatable\Translatable; |
8
|
|
|
use Doctrine\ORM\Mapping as ORM; |
9
|
|
|
use Doctrine\ORM\Mapping\HasLifecycleCallbacks; |
10
|
|
|
use Zend\InputFilter\InputFilter; |
11
|
|
|
use Zend\InputFilter\Factory as InputFactory; |
12
|
|
|
use Zend\InputFilter\InputFilterAwareInterface; |
13
|
|
|
use Zend\InputFilter\InputFilterInterface; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* @ORM\Entity @HasLifecycleCallbacks |
17
|
|
|
* @ORM\Table(name="game_postvote") |
18
|
|
|
*/ |
19
|
|
|
class PostVote extends Game implements InputFilterAwareInterface |
20
|
|
|
{ |
21
|
|
|
const CLASSTYPE = 'postvote'; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Display mode of Posts : |
25
|
|
|
* 'date' : sort by post date desc |
26
|
|
|
* 'random' : ... |
27
|
|
|
* 'votes' : sort by number of vote desc |
28
|
|
|
* |
29
|
|
|
* @ORM\Column(name="post_display_mode", type="string", nullable=false) |
30
|
|
|
*/ |
31
|
|
|
protected $postDisplayMode = 'date'; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Number of Post displayed : |
35
|
|
|
* 0 : infinite |
36
|
|
|
* |
37
|
|
|
* @ORM\Column(name="post_display_number", type="integer", nullable=false) |
38
|
|
|
*/ |
39
|
|
|
protected $postDisplayNumber = 0; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Is it possible to vote ? |
43
|
|
|
* @ORM\Column(name="vote_active", type="boolean", nullable=false) |
44
|
|
|
*/ |
45
|
|
|
protected $voteActive = 1; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Is it possible to vote anonymously ? |
49
|
|
|
* @ORM\Column(name="vote_anonymous", type="boolean", nullable=false) |
50
|
|
|
*/ |
51
|
|
|
protected $voteAnonymous; |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Type of moderation : moderate posts before their publication, or after their publication (default) |
55
|
|
|
* @ORM\Column(name="moderation_type", type="boolean", nullable=false, options={"default" = 0}) |
56
|
|
|
*/ |
57
|
|
|
protected $moderationType = 0; |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @ORM\Column(name="mail_moderation_validated",type="boolean", nullable=true) |
61
|
|
|
*/ |
62
|
|
|
protected $mailModerationValidated = 0; |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @Gedmo\Translatable |
66
|
|
|
* @ORM\Column(name="mail_moderation_validated_block", type="text", nullable=true) |
67
|
|
|
*/ |
68
|
|
|
protected $mailModerationValidatedBlock; |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* @ORM\Column(name="mail_moderation_rejected",type="boolean", nullable=true) |
72
|
|
|
*/ |
73
|
|
|
protected $mailModerationRejected = 0; |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* @Gedmo\Translatable |
77
|
|
|
* @ORM\Column(name="mail_moderation_rejected_block", type="text", nullable=true) |
78
|
|
|
*/ |
79
|
|
|
protected $mailModerationRejectedBlock; |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* @ORM\OneToOne(targetEntity="PostVoteForm", mappedBy="postvote", cascade={"persist","remove"}) |
83
|
|
|
**/ |
84
|
|
|
private $form; |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* @ORM\OneToMany(targetEntity="PostVotePost", mappedBy="postvote") |
88
|
|
|
**/ |
89
|
|
|
private $posts; |
90
|
|
|
|
91
|
|
|
public function __construct() |
92
|
|
|
{ |
93
|
|
|
parent::__construct(); |
94
|
|
|
$this->setClassType(self::CLASSTYPE); |
95
|
|
|
$this->posts = new ArrayCollection(); |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* Add a post to the game |
100
|
|
|
* |
101
|
|
|
* @param PostVotePost $post |
102
|
|
|
* |
103
|
|
|
* @return void |
104
|
|
|
*/ |
105
|
|
|
public function addPost($post) |
106
|
|
|
{ |
107
|
|
|
$this->post[] = $post; |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
public function getPosts() |
111
|
|
|
{ |
112
|
|
|
return $this->posts; |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
public function setPosts($posts) |
116
|
|
|
{ |
117
|
|
|
$this->posts = $posts; |
118
|
|
|
|
119
|
|
|
return $this; |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
/** |
123
|
|
|
* @return the unknown_type |
124
|
|
|
*/ |
125
|
|
|
public function getForm() |
126
|
|
|
{ |
127
|
|
|
return $this->form; |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
/** |
131
|
|
|
* @param unknown_type $form |
132
|
|
|
*/ |
133
|
|
|
public function setForm($form) |
134
|
|
|
{ |
135
|
|
|
$this->form = $form; |
136
|
|
|
|
137
|
|
|
return $this; |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
/** |
141
|
|
|
* @return string unknown_type |
142
|
|
|
*/ |
143
|
|
|
public function getPostDisplayMode() |
144
|
|
|
{ |
145
|
|
|
return $this->postDisplayMode; |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
/** |
149
|
|
|
* @param unknown_type $postDisplayMode |
150
|
|
|
*/ |
151
|
|
|
public function setPostDisplayMode($postDisplayMode) |
152
|
|
|
{ |
153
|
|
|
$this->postDisplayMode = $postDisplayMode; |
|
|
|
|
154
|
|
|
|
155
|
|
|
return $this; |
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
/** |
159
|
|
|
* @return int |
160
|
|
|
*/ |
161
|
|
|
public function getPostDisplayNumber() |
162
|
|
|
{ |
163
|
|
|
return $this->postDisplayNumber; |
164
|
|
|
} |
165
|
|
|
|
166
|
|
|
/** |
167
|
|
|
* @param int $postDisplayNumber |
168
|
|
|
* |
169
|
|
|
* @return PostVote |
170
|
|
|
*/ |
171
|
|
|
public function setPostDisplayNumber($postDisplayNumber) |
172
|
|
|
{ |
173
|
|
|
$this->postDisplayNumber = $postDisplayNumber; |
174
|
|
|
|
175
|
|
|
return $this; |
176
|
|
|
} |
177
|
|
|
|
178
|
|
|
/** |
179
|
|
|
* @return the unknown_type |
180
|
|
|
*/ |
181
|
|
|
public function getVoteActive() |
182
|
|
|
{ |
183
|
|
|
return $this->voteActive; |
184
|
|
|
} |
185
|
|
|
|
186
|
|
|
/** |
187
|
|
|
* @param unknown_type $voteActive |
188
|
|
|
*/ |
189
|
|
|
public function setVoteActive($voteActive) |
190
|
|
|
{ |
191
|
|
|
$this->voteActive = $voteActive; |
|
|
|
|
192
|
|
|
|
193
|
|
|
return $this; |
194
|
|
|
} |
195
|
|
|
|
196
|
|
|
/** |
197
|
|
|
* @return the unknown_type |
198
|
|
|
*/ |
199
|
|
|
public function getVoteAnonymous() |
200
|
|
|
{ |
201
|
|
|
return $this->voteAnonymous; |
202
|
|
|
} |
203
|
|
|
|
204
|
|
|
/** |
205
|
|
|
* @param unknown_type $voteAnonymous |
206
|
|
|
*/ |
207
|
|
|
public function setVoteAnonymous($voteAnonymous) |
208
|
|
|
{ |
209
|
|
|
$this->voteAnonymous = $voteAnonymous; |
210
|
|
|
|
211
|
|
|
return $this; |
212
|
|
|
} |
213
|
|
|
|
214
|
|
|
/** |
215
|
|
|
* @return bool |
216
|
|
|
*/ |
217
|
|
|
public function getModerationType() |
218
|
|
|
{ |
219
|
|
|
return $this->moderationType; |
220
|
|
|
} |
221
|
|
|
|
222
|
|
|
/** |
223
|
|
|
* @param bool $moderationType |
224
|
|
|
*/ |
225
|
|
|
public function setModerationType($moderationType) |
226
|
|
|
{ |
227
|
|
|
$this->moderationType = $moderationType; |
|
|
|
|
228
|
|
|
|
229
|
|
|
return $this; |
230
|
|
|
} |
231
|
|
|
|
232
|
|
|
/** |
233
|
|
|
* @return bool |
234
|
|
|
*/ |
235
|
|
|
public function getMailModerationValidated() |
236
|
|
|
{ |
237
|
|
|
return $this->mailModerationValidated; |
238
|
|
|
} |
239
|
|
|
|
240
|
|
|
/** |
241
|
|
|
* @param bool $mailModerationValidated |
242
|
|
|
*/ |
243
|
|
|
public function setMailModerationValidated($mailModerationValidated) |
244
|
|
|
{ |
245
|
|
|
$this->mailModerationValidated = $mailModerationValidated; |
|
|
|
|
246
|
|
|
|
247
|
|
|
return $this; |
248
|
|
|
} |
249
|
|
|
|
250
|
|
|
/** |
251
|
|
|
* @return bool |
252
|
|
|
*/ |
253
|
|
|
public function getMailModerationValidatedBlock() |
254
|
|
|
{ |
255
|
|
|
return $this->mailModerationValidatedBlock; |
256
|
|
|
} |
257
|
|
|
|
258
|
|
|
/** |
259
|
|
|
* @param bool $mailModerationValidatedBlock |
260
|
|
|
*/ |
261
|
|
|
public function setMailModerationValidatedBlock($mailModerationValidatedBlock) |
262
|
|
|
{ |
263
|
|
|
$this->mailModerationValidatedBlock = $mailModerationValidatedBlock; |
264
|
|
|
|
265
|
|
|
return $this; |
266
|
|
|
} |
267
|
|
|
|
268
|
|
|
/** |
269
|
|
|
* @return bool |
270
|
|
|
*/ |
271
|
|
|
public function getMailModerationRejected() |
272
|
|
|
{ |
273
|
|
|
return $this->mailModerationRejected; |
274
|
|
|
} |
275
|
|
|
|
276
|
|
|
/** |
277
|
|
|
* @param bool $mailModerationRejected |
278
|
|
|
*/ |
279
|
|
|
public function setMailModerationRejected($mailModerationRejected) |
280
|
|
|
{ |
281
|
|
|
$this->mailModerationRejected = $mailModerationRejected; |
|
|
|
|
282
|
|
|
|
283
|
|
|
return $this; |
284
|
|
|
} |
285
|
|
|
|
286
|
|
|
/** |
287
|
|
|
* @return bool |
288
|
|
|
*/ |
289
|
|
|
public function getMailModerationRejectedBlock() |
290
|
|
|
{ |
291
|
|
|
return $this->mailModerationRejectedBlock; |
292
|
|
|
} |
293
|
|
|
|
294
|
|
|
/** |
295
|
|
|
* @param bool $mailModerationRejectedBlock |
296
|
|
|
*/ |
297
|
|
|
public function setMailModerationRejectedBlock($mailModerationRejectedBlock) |
298
|
|
|
{ |
299
|
|
|
$this->mailModerationRejectedBlock = $mailModerationRejectedBlock; |
300
|
|
|
|
301
|
|
|
return $this; |
302
|
|
|
} |
303
|
|
|
|
304
|
|
|
/** |
305
|
|
|
* Convert the object to an array. |
306
|
|
|
* |
307
|
|
|
* @return array |
308
|
|
|
*/ |
309
|
|
|
public function getArrayCopy() |
310
|
|
|
{ |
311
|
|
|
$obj_vars = parent::getArrayCopy(); |
312
|
|
|
array_merge($obj_vars, get_object_vars($this)); |
313
|
|
|
|
314
|
|
|
return $obj_vars; |
315
|
|
|
} |
316
|
|
|
|
317
|
|
|
/** |
318
|
|
|
* Populate from an array. |
319
|
|
|
* |
320
|
|
|
* @param array $data |
321
|
|
|
*/ |
322
|
|
View Code Duplication |
public function populate($data = array()) |
|
|
|
|
323
|
|
|
{ |
324
|
|
|
parent::populate($data); |
325
|
|
|
|
326
|
|
|
if (isset($data['postDisplayMode']) && $data['postDisplayMode'] !== null) { |
327
|
|
|
$this->postDisplayMode = $data['postDisplayMode']; |
328
|
|
|
} |
329
|
|
|
|
330
|
|
|
if (isset($data['voteAnonymous']) && $data['voteAnonymous'] !== null) { |
331
|
|
|
$this->voteAnonymous = $data['voteAnonymous']; |
332
|
|
|
} |
333
|
|
|
} |
334
|
|
|
|
335
|
|
|
public function setInputFilter(InputFilterInterface $inputFilter) |
336
|
|
|
{ |
337
|
|
|
throw new \Exception("Not used"); |
338
|
|
|
} |
339
|
|
|
|
340
|
|
|
public function getInputFilter() |
341
|
|
|
{ |
342
|
|
|
if (!$this->inputFilter) { |
343
|
|
|
$inputFilter = new InputFilter(); |
|
|
|
|
344
|
|
|
$factory = new InputFactory(); |
345
|
|
|
|
346
|
|
|
$inputFilter = parent::getInputFilter(); |
347
|
|
|
|
348
|
|
|
$inputFilter->add( |
349
|
|
|
$factory->createInput( |
350
|
|
|
array( |
351
|
|
|
'name' => 'postDisplayMode', |
352
|
|
|
'required' => false, |
353
|
|
|
'validators' => array( |
354
|
|
|
array( |
355
|
|
|
'name' => 'InArray', |
356
|
|
|
'options' => array( |
357
|
|
|
'haystack' => array('date', 'vote', 'random'), |
358
|
|
|
), |
359
|
|
|
), |
360
|
|
|
), |
361
|
|
|
) |
362
|
|
|
) |
363
|
|
|
); |
364
|
|
|
|
365
|
|
|
$inputFilter->add( |
366
|
|
|
$factory->createInput( |
367
|
|
|
array( |
368
|
|
|
'name' => 'voteActive', |
369
|
|
|
'required' => true, |
370
|
|
|
'validators' => array( |
371
|
|
|
array( |
372
|
|
|
'name' => 'Between', |
373
|
|
|
'options' => array('min' => 0, 'max' => 1), |
374
|
|
|
), |
375
|
|
|
), |
376
|
|
|
) |
377
|
|
|
) |
378
|
|
|
); |
379
|
|
|
|
380
|
|
|
$inputFilter->add( |
381
|
|
|
$factory->createInput( |
382
|
|
|
array( |
383
|
|
|
'name' => 'voteAnonymous', |
384
|
|
|
'required' => true, |
385
|
|
|
'validators' => array( |
386
|
|
|
array( |
387
|
|
|
'name' => 'Between', |
388
|
|
|
'options' => array('min' => 0, 'max' => 1), |
389
|
|
|
), |
390
|
|
|
), |
391
|
|
|
) |
392
|
|
|
) |
393
|
|
|
); |
394
|
|
|
|
395
|
|
|
$inputFilter->add( |
396
|
|
|
$factory->createInput( |
397
|
|
|
array( |
398
|
|
|
'name' => 'moderationType', |
399
|
|
|
'required' => false, |
400
|
|
|
'validators' => array( |
401
|
|
|
array( |
402
|
|
|
'name' => 'Between', |
403
|
|
|
'options' => array('min' => 0, 'max' => 1), |
404
|
|
|
), |
405
|
|
|
), |
406
|
|
|
) |
407
|
|
|
) |
408
|
|
|
); |
409
|
|
|
|
410
|
|
|
$this->inputFilter = $inputFilter; |
411
|
|
|
} |
412
|
|
|
|
413
|
|
|
return $this->inputFilter; |
414
|
|
|
} |
415
|
|
|
} |
416
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..