|
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
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* An entry represent a game session. |
|
11
|
|
|
* @ORM\Entity @HasLifecycleCallbacks |
|
12
|
|
|
* @ORM\Table(name="game_entry") |
|
13
|
|
|
*/ |
|
14
|
|
|
class Entry implements \JsonSerializable |
|
15
|
|
|
{ |
|
16
|
|
|
/** |
|
17
|
|
|
* @ORM\Id |
|
18
|
|
|
* @ORM\Column(type="integer"); |
|
19
|
|
|
* @ORM\GeneratedValue(strategy="AUTO") |
|
20
|
|
|
*/ |
|
21
|
|
|
protected $id; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* @ORM\ManyToOne(targetEntity="Game", cascade={"persist","remove"}) |
|
25
|
|
|
* @ORM\JoinColumn(name="game_id", referencedColumnName="id", onDelete="CASCADE") |
|
26
|
|
|
**/ |
|
27
|
|
|
protected $game; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @ORM\ManyToOne(targetEntity="PlaygroundUser\Entity\User") |
|
31
|
|
|
* @ORM\JoinColumn(name="user_id", referencedColumnName="user_id", onDelete="CASCADE") |
|
32
|
|
|
**/ |
|
33
|
|
|
protected $user; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* @ORM\Column(type="boolean", nullable=true) |
|
37
|
|
|
*/ |
|
38
|
|
|
protected $active = 1; |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* An entry marked as bonus means that it's not taken into account |
|
42
|
|
|
* in the limit calculation. It's offered, for example, when you share the game to a friend. |
|
43
|
|
|
* |
|
44
|
|
|
* @ORM\Column(type="boolean", nullable=true) |
|
45
|
|
|
*/ |
|
46
|
|
|
protected $bonus = 0; |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* @ORM\Column(type="integer", nullable=true) |
|
50
|
|
|
*/ |
|
51
|
|
|
protected $points; |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* @ORM\Column(type="string", length=255, nullable=true) |
|
55
|
|
|
*/ |
|
56
|
|
|
protected $ip; |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* @ORM\Column(type="string", length=255, nullable=true) |
|
60
|
|
|
*/ |
|
61
|
|
|
protected $geoloc; |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* @ORM\Column(name="anonymous_id", type="string", length=255, nullable=true) |
|
65
|
|
|
*/ |
|
66
|
|
|
protected $anonymousId; |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* This column hosts an id chosen by the admin in case of a game with "anonymous" participation : |
|
70
|
|
|
* This is a value chosen from the playerData (generally "email"). |
|
71
|
|
|
* |
|
72
|
|
|
* @ORM\Column(name="anonymous_identifier", type="string", length=255, nullable=true) |
|
73
|
|
|
*/ |
|
74
|
|
|
protected $anonymousIdentifier; |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* @ORM\Column(name="player_data", type="text", nullable=true) |
|
78
|
|
|
*/ |
|
79
|
|
|
protected $playerData; |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* @ORM\Column(name="social_shares", type="text", nullable=true) |
|
83
|
|
|
*/ |
|
84
|
|
|
protected $socialShares; |
|
85
|
|
|
|
|
86
|
|
|
/** |
|
87
|
|
|
* Is this entry a winning one ? |
|
88
|
|
|
* @ORM\Column(type="boolean", nullable=true) |
|
89
|
|
|
*/ |
|
90
|
|
|
protected $winner = 0; |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* Is there a termsOptin on this entry ? |
|
94
|
|
|
* @ORM\Column(name="terms_optin", type="boolean", nullable=true) |
|
95
|
|
|
*/ |
|
96
|
|
|
protected $termsOptin; |
|
97
|
|
|
|
|
98
|
|
|
/** |
|
99
|
|
|
* Is this entry eligible to draw ? |
|
100
|
|
|
* @ORM\Column(type="boolean", nullable=true) |
|
101
|
|
|
*/ |
|
102
|
|
|
protected $drawable = 0; |
|
103
|
|
|
|
|
104
|
|
|
/** |
|
105
|
|
|
* @ORM\Column(type="datetime") |
|
106
|
|
|
*/ |
|
107
|
|
|
protected $created_at; |
|
108
|
|
|
|
|
109
|
|
|
/** |
|
110
|
|
|
* The step in the play (in a quiz for example : the nth question) |
|
111
|
|
|
* @ORM\Column(type="integer", nullable=true) |
|
112
|
|
|
*/ |
|
113
|
|
|
protected $step = 0; |
|
114
|
|
|
|
|
115
|
|
|
/** |
|
116
|
|
|
* @ORM\Column(type="datetime") |
|
117
|
|
|
*/ |
|
118
|
|
|
protected $updated_at; |
|
119
|
|
|
|
|
120
|
|
|
public function __construct() |
|
121
|
|
|
{ |
|
122
|
|
|
} |
|
123
|
|
|
|
|
124
|
|
|
/** @PrePersist */ |
|
125
|
|
|
public function createChrono() |
|
126
|
|
|
{ |
|
127
|
|
|
$this->created_at = new \DateTime("now"); |
|
128
|
|
|
$this->updated_at = new \DateTime("now"); |
|
129
|
|
|
} |
|
130
|
|
|
|
|
131
|
|
|
/** @PreUpdate */ |
|
132
|
|
|
public function updateChrono() |
|
133
|
|
|
{ |
|
134
|
|
|
$this->updated_at = new \DateTime("now"); |
|
135
|
|
|
} |
|
136
|
|
|
|
|
137
|
|
|
/** |
|
138
|
|
|
* |
|
139
|
|
|
* @return the $id |
|
140
|
|
|
*/ |
|
141
|
|
|
public function getId() |
|
142
|
|
|
{ |
|
143
|
|
|
return $this->id; |
|
144
|
|
|
} |
|
145
|
|
|
|
|
146
|
|
|
/** |
|
147
|
|
|
* |
|
148
|
|
|
* @param field_type $id |
|
149
|
|
|
*/ |
|
150
|
|
|
public function setId($id) |
|
151
|
|
|
{ |
|
152
|
|
|
$this->id = $id; |
|
153
|
|
|
|
|
154
|
|
|
return $this; |
|
155
|
|
|
} |
|
156
|
|
|
|
|
157
|
|
|
/** |
|
158
|
|
|
* @return the $game |
|
159
|
|
|
*/ |
|
160
|
|
|
public function getGame() |
|
161
|
|
|
{ |
|
162
|
|
|
return $this->game; |
|
163
|
|
|
} |
|
164
|
|
|
|
|
165
|
|
|
/** |
|
166
|
|
|
* @param field_type $game |
|
167
|
|
|
*/ |
|
168
|
|
|
public function setGame($game) |
|
169
|
|
|
{ |
|
170
|
|
|
$this->game = $game; |
|
171
|
|
|
|
|
172
|
|
|
return $this; |
|
173
|
|
|
} |
|
174
|
|
|
|
|
175
|
|
|
/** |
|
176
|
|
|
* @return the $user |
|
177
|
|
|
*/ |
|
178
|
|
|
public function getUser() |
|
179
|
|
|
{ |
|
180
|
|
|
return $this->user; |
|
181
|
|
|
} |
|
182
|
|
|
|
|
183
|
|
|
/** |
|
184
|
|
|
* @param field_type $user |
|
185
|
|
|
*/ |
|
186
|
|
|
public function setUser($user) |
|
187
|
|
|
{ |
|
188
|
|
|
$this->user = $user; |
|
189
|
|
|
|
|
190
|
|
|
return $this; |
|
191
|
|
|
} |
|
192
|
|
|
|
|
193
|
|
|
/** |
|
194
|
|
|
* @return integer $points |
|
195
|
|
|
*/ |
|
196
|
|
|
public function getPoints() |
|
197
|
|
|
{ |
|
198
|
|
|
return $this->points; |
|
199
|
|
|
} |
|
200
|
|
|
|
|
201
|
|
|
/** |
|
202
|
|
|
* @param integer $points |
|
203
|
|
|
*/ |
|
204
|
|
|
public function setPoints($points) |
|
205
|
|
|
{ |
|
206
|
|
|
$this->points = $points; |
|
207
|
|
|
|
|
208
|
|
|
return $this; |
|
209
|
|
|
} |
|
210
|
|
|
|
|
211
|
|
|
/** |
|
212
|
|
|
* @return the $ip |
|
213
|
|
|
*/ |
|
214
|
|
|
public function getIp() |
|
215
|
|
|
{ |
|
216
|
|
|
return $this->ip; |
|
217
|
|
|
} |
|
218
|
|
|
|
|
219
|
|
|
/** |
|
220
|
|
|
* @param field_type $ip |
|
221
|
|
|
*/ |
|
222
|
|
|
public function setIp($ip) |
|
223
|
|
|
{ |
|
224
|
|
|
$this->ip = $ip; |
|
225
|
|
|
|
|
226
|
|
|
return $this; |
|
227
|
|
|
} |
|
228
|
|
|
|
|
229
|
|
|
/** |
|
230
|
|
|
* @return the $geoloc |
|
231
|
|
|
*/ |
|
232
|
|
|
public function getGeoloc() |
|
233
|
|
|
{ |
|
234
|
|
|
return $this->geoloc; |
|
235
|
|
|
} |
|
236
|
|
|
|
|
237
|
|
|
/** |
|
238
|
|
|
* @param field_type $geoloc |
|
239
|
|
|
*/ |
|
240
|
|
|
public function setGeoloc($geoloc) |
|
241
|
|
|
{ |
|
242
|
|
|
$this->geoloc = $geoloc; |
|
243
|
|
|
|
|
244
|
|
|
return $this; |
|
245
|
|
|
} |
|
246
|
|
|
|
|
247
|
|
|
/** |
|
248
|
|
|
* @return the $anonymousId |
|
249
|
|
|
*/ |
|
250
|
|
|
public function getAnonymousId() |
|
251
|
|
|
{ |
|
252
|
|
|
return $this->anonymousId; |
|
253
|
|
|
} |
|
254
|
|
|
|
|
255
|
|
|
/** |
|
256
|
|
|
* @param field_type $anonymousId |
|
257
|
|
|
*/ |
|
258
|
|
|
public function setAnonymousId($anonymousId) |
|
259
|
|
|
{ |
|
260
|
|
|
$this->anonymousId = $anonymousId; |
|
261
|
|
|
|
|
262
|
|
|
return $this; |
|
263
|
|
|
} |
|
264
|
|
|
|
|
265
|
|
|
/** |
|
266
|
|
|
* @return the $anonymousIdentifier |
|
267
|
|
|
*/ |
|
268
|
|
|
public function getAnonymousIdentifier() |
|
269
|
|
|
{ |
|
270
|
|
|
return $this->anonymousIdentifier; |
|
271
|
|
|
} |
|
272
|
|
|
|
|
273
|
|
|
/** |
|
274
|
|
|
* @param field_type $anonymousIdentifier |
|
275
|
|
|
*/ |
|
276
|
|
|
public function setAnonymousIdentifier($anonymousIdentifier) |
|
277
|
|
|
{ |
|
278
|
|
|
$this->anonymousIdentifier = $anonymousIdentifier; |
|
279
|
|
|
} |
|
280
|
|
|
|
|
281
|
|
|
/** |
|
282
|
|
|
* @return the $playerData |
|
283
|
|
|
*/ |
|
284
|
|
|
public function getPlayerData() |
|
285
|
|
|
{ |
|
286
|
|
|
return $this->playerData; |
|
287
|
|
|
} |
|
288
|
|
|
|
|
289
|
|
|
/** |
|
290
|
|
|
* @param field_type $playerData |
|
291
|
|
|
*/ |
|
292
|
|
|
public function setPlayerData($playerData) |
|
293
|
|
|
{ |
|
294
|
|
|
$this->playerData = $playerData; |
|
295
|
|
|
|
|
296
|
|
|
return $this; |
|
297
|
|
|
} |
|
298
|
|
|
|
|
299
|
|
|
/** |
|
300
|
|
|
* @return the $socialShares |
|
301
|
|
|
*/ |
|
302
|
|
|
public function getSocialShares() |
|
303
|
|
|
{ |
|
304
|
|
|
return $this->socialShares; |
|
305
|
|
|
} |
|
306
|
|
|
|
|
307
|
|
|
/** |
|
308
|
|
|
* @param field_type $socialShares |
|
309
|
|
|
*/ |
|
310
|
|
|
public function setSocialShares($socialShares) |
|
311
|
|
|
{ |
|
312
|
|
|
$this->socialShares = $socialShares; |
|
313
|
|
|
} |
|
314
|
|
|
|
|
315
|
|
|
/** |
|
316
|
|
|
* @return integer status |
|
317
|
|
|
*/ |
|
318
|
|
|
public function getActive() |
|
319
|
|
|
{ |
|
320
|
|
|
return $this->active; |
|
321
|
|
|
} |
|
322
|
|
|
|
|
323
|
|
|
/** |
|
324
|
|
|
* @param integer $active |
|
325
|
|
|
*/ |
|
326
|
|
|
public function setActive($active) |
|
327
|
|
|
{ |
|
328
|
|
|
$this->active = $active; |
|
329
|
|
|
|
|
330
|
|
|
return $this; |
|
331
|
|
|
} |
|
332
|
|
|
|
|
333
|
|
|
/** |
|
334
|
|
|
* @return integer $step |
|
335
|
|
|
*/ |
|
336
|
|
|
public function getStep() |
|
337
|
|
|
{ |
|
338
|
|
|
return $this->step; |
|
339
|
|
|
} |
|
340
|
|
|
|
|
341
|
|
|
/** |
|
342
|
|
|
* @param number $step |
|
343
|
|
|
*/ |
|
344
|
|
|
public function setStep($step) |
|
345
|
|
|
{ |
|
346
|
|
|
$this->step = $step; |
|
|
|
|
|
|
347
|
|
|
} |
|
348
|
|
|
|
|
349
|
|
|
/** |
|
350
|
|
|
* @return integer bonus |
|
351
|
|
|
*/ |
|
352
|
|
|
public function getBonus() |
|
353
|
|
|
{ |
|
354
|
|
|
return $this->bonus; |
|
355
|
|
|
} |
|
356
|
|
|
|
|
357
|
|
|
/** |
|
358
|
|
|
* @param integer $bonus |
|
359
|
|
|
*/ |
|
360
|
|
|
public function setBonus($bonus) |
|
361
|
|
|
{ |
|
362
|
|
|
$this->bonus = $bonus; |
|
363
|
|
|
|
|
364
|
|
|
return $this; |
|
365
|
|
|
} |
|
366
|
|
|
|
|
367
|
|
|
/** |
|
368
|
|
|
* @return integer status |
|
369
|
|
|
*/ |
|
370
|
|
|
public function getWinner() |
|
371
|
|
|
{ |
|
372
|
|
|
return $this->winner; |
|
373
|
|
|
} |
|
374
|
|
|
|
|
375
|
|
|
/** |
|
376
|
|
|
* @param integer $winner |
|
377
|
|
|
*/ |
|
378
|
|
|
public function setWinner($winner) |
|
379
|
|
|
{ |
|
380
|
|
|
$this->winner = $winner; |
|
381
|
|
|
|
|
382
|
|
|
return $this; |
|
383
|
|
|
} |
|
384
|
|
|
|
|
385
|
|
|
/** |
|
386
|
|
|
* @return integer $drawable |
|
387
|
|
|
*/ |
|
388
|
|
|
public function getDrawable() |
|
389
|
|
|
{ |
|
390
|
|
|
return $this->drawable; |
|
391
|
|
|
} |
|
392
|
|
|
|
|
393
|
|
|
/** |
|
394
|
|
|
* @param number $drawable |
|
395
|
|
|
*/ |
|
396
|
|
|
public function setDrawable($drawable) |
|
397
|
|
|
{ |
|
398
|
|
|
$this->drawable = $drawable; |
|
|
|
|
|
|
399
|
|
|
|
|
400
|
|
|
return $this; |
|
401
|
|
|
} |
|
402
|
|
|
|
|
403
|
|
|
/** |
|
404
|
|
|
* @return the termsOptin |
|
405
|
|
|
*/ |
|
406
|
|
|
public function getTermsOptin() |
|
407
|
|
|
{ |
|
408
|
|
|
return $this->termsOptin; |
|
409
|
|
|
} |
|
410
|
|
|
|
|
411
|
|
|
/** |
|
412
|
|
|
* @param field_type $termsOptin |
|
413
|
|
|
*/ |
|
414
|
|
|
public function setTermsOptin($termsOptin) |
|
415
|
|
|
{ |
|
416
|
|
|
$this->termsOptin = $termsOptin; |
|
417
|
|
|
|
|
418
|
|
|
return $this; |
|
419
|
|
|
} |
|
420
|
|
|
|
|
421
|
|
|
/** |
|
422
|
|
|
* @return \DateTime $created_at |
|
423
|
|
|
*/ |
|
424
|
|
|
public function getCreatedAt() |
|
425
|
|
|
{ |
|
426
|
|
|
return $this->created_at; |
|
427
|
|
|
} |
|
428
|
|
|
|
|
429
|
|
|
/** |
|
430
|
|
|
* @param \DateTime $created_at |
|
431
|
|
|
*/ |
|
432
|
|
|
public function setCreatedAt($created_at) |
|
433
|
|
|
{ |
|
434
|
|
|
$this->created_at = $created_at; |
|
435
|
|
|
|
|
436
|
|
|
return $this; |
|
437
|
|
|
} |
|
438
|
|
|
|
|
439
|
|
|
/** |
|
440
|
|
|
* @return \DateTime $updated_at |
|
441
|
|
|
*/ |
|
442
|
|
|
public function getUpdatedAt() |
|
443
|
|
|
{ |
|
444
|
|
|
return $this->updated_at; |
|
445
|
|
|
} |
|
446
|
|
|
|
|
447
|
|
|
/** |
|
448
|
|
|
* @param \DateTime $updated_at |
|
449
|
|
|
*/ |
|
450
|
|
|
public function setUpdatedAt($updated_at) |
|
451
|
|
|
{ |
|
452
|
|
|
$this->updated_at = $updated_at; |
|
453
|
|
|
|
|
454
|
|
|
return $this; |
|
455
|
|
|
} |
|
456
|
|
|
|
|
457
|
|
|
/** |
|
458
|
|
|
* Convert the object to an array. |
|
459
|
|
|
* |
|
460
|
|
|
* @return array |
|
461
|
|
|
*/ |
|
462
|
|
|
public function getArrayCopy() |
|
463
|
|
|
{ |
|
464
|
|
|
return get_object_vars($this); |
|
465
|
|
|
} |
|
466
|
|
|
|
|
467
|
|
|
/** |
|
468
|
|
|
* Convert the object to json. |
|
469
|
|
|
* |
|
470
|
|
|
* @return array |
|
471
|
|
|
*/ |
|
472
|
|
|
public function jsonSerialize() |
|
473
|
|
|
{ |
|
474
|
|
|
return $this->getArrayCopy(); |
|
475
|
|
|
} |
|
476
|
|
|
|
|
477
|
|
|
/** |
|
478
|
|
|
* Populate from an array. |
|
479
|
|
|
* |
|
480
|
|
|
* @param array $data |
|
481
|
|
|
*/ |
|
482
|
|
|
public function populate($data = array()) |
|
|
|
|
|
|
483
|
|
|
{ |
|
484
|
|
|
} |
|
485
|
|
|
} |
|
486
|
|
|
|
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.
For example, imagine you have a variable
$accountIdthat can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to theidproperty of an instance of theAccountclass. This class holds a proper account, so the id value must no longer be false.Either this assignment is in error or a type check should be added for that assignment.