1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace VideoGamesRecords\CoreBundle\Entity; |
4
|
|
|
|
5
|
|
|
use Doctrine\ORM\Mapping as ORM; |
6
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
7
|
|
|
use Knp\DoctrineBehaviors\Model\Sluggable\Sluggable; |
8
|
|
|
use Knp\DoctrineBehaviors\Model\Timestampable\Timestampable; |
9
|
|
|
use Knp\DoctrineBehaviors\Model\Translatable\Translatable; |
10
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
11
|
|
|
use ProjetNormandie\BadgeBundle\Entity\Badge; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Game |
15
|
|
|
* |
16
|
|
|
* @ORM\Table(name="vgr_game", indexes={@ORM\Index(name="idxStatus", columns={"status"}), @ORM\Index(name="idxEtat", columns={"etat"}), @ORM\Index(name="idxSerie", columns={"idSerie"})}) |
17
|
|
|
* @ORM\Entity(repositoryClass="VideoGamesRecords\CoreBundle\Repository\GameRepository") |
18
|
|
|
* @method GameTranslation translate(string $locale, bool $fallbackToDefault) |
19
|
|
|
* @todo check etat / imagePlateforme / ordre |
20
|
|
|
*/ |
21
|
|
|
class Game |
22
|
|
|
{ |
23
|
|
|
use Timestampable; |
24
|
|
|
use Translatable; |
25
|
|
|
use Sluggable; |
26
|
|
|
|
27
|
|
|
const NUM_ITEMS = 20; |
28
|
|
|
|
29
|
|
|
const STATUS_ACTIVE = 'ACTIF'; |
30
|
|
|
const STATUS_INACTIVE = 'INACTIF'; |
31
|
|
|
|
32
|
|
|
const ETAT_INIT = 'CREATION'; |
33
|
|
|
const ETAT_CHART = 'RECORD'; |
34
|
|
|
const ETAT_PICTURE = 'IMAGE'; |
35
|
|
|
const ETAT_END = 'FINI'; |
36
|
|
|
|
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @var integer |
40
|
|
|
* |
41
|
|
|
* @ORM\Column(name="id", type="integer") |
42
|
|
|
* @ORM\Id |
43
|
|
|
* @ORM\GeneratedValue(strategy="IDENTITY") |
44
|
|
|
*/ |
45
|
|
|
private $id; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @var string |
49
|
|
|
* |
50
|
|
|
* @Assert\Length(max="200") |
51
|
|
|
* @ORM\Column(name="picture", type="string", length=200, nullable=true) |
52
|
|
|
*/ |
53
|
|
|
private $picture; |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @var string |
57
|
|
|
* |
58
|
|
|
* @ORM\Column(name="status", type="string", nullable=false) |
59
|
|
|
*/ |
60
|
|
|
private $status = self::STATUS_INACTIVE; |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @var string |
64
|
|
|
* |
65
|
|
|
* @ORM\Column(name="etat", type="string", nullable=false) |
66
|
|
|
*/ |
67
|
|
|
private $etat = self::ETAT_INIT; |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @var \DateTime |
71
|
|
|
* |
72
|
|
|
* @ORM\Column(name="dateActivation", type="datetime", nullable=true) |
73
|
|
|
*/ |
74
|
|
|
private $dateActivation; |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @var boolean |
78
|
|
|
* |
79
|
|
|
* @ORM\Column(name="boolDlc", type="boolean", nullable=false, options={"default":0}) |
80
|
|
|
*/ |
81
|
|
|
private $boolDlc = false; |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @var integer |
85
|
|
|
* |
86
|
|
|
* @ORM\Column(name="nbChart", type="integer", nullable=false, options={"default":0}) |
87
|
|
|
*/ |
88
|
|
|
private $nbChart = 0; |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* @var integer |
92
|
|
|
* |
93
|
|
|
* @ORM\Column(name="nbPost", type="integer", nullable=false, options={"default":0}) |
94
|
|
|
*/ |
95
|
|
|
private $nbPost = 0; |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* @var integer |
99
|
|
|
* |
100
|
|
|
* @ORM\Column(name="nbPlayer", type="integer", nullable=false, options={"default":0}) |
101
|
|
|
*/ |
102
|
|
|
private $nbPlayer = 0; |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* @var integer |
106
|
|
|
* |
107
|
|
|
* @ORM\Column(name="nbTeam", type="integer", nullable=false, options={"default":0}) |
108
|
|
|
*/ |
109
|
|
|
private $nbTeam = 0; |
110
|
|
|
|
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* @var integer |
114
|
|
|
* |
115
|
|
|
* @ORM\Column(name="ordre", type="integer", nullable=true) |
116
|
|
|
*/ |
117
|
|
|
private $ordre; |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* @var Serie |
121
|
|
|
* |
122
|
|
|
* @ORM\ManyToOne(targetEntity="VideoGamesRecords\CoreBundle\Entity\Serie") |
123
|
|
|
* @ORM\JoinColumns({ |
124
|
|
|
* @ORM\JoinColumn(name="idSerie", referencedColumnName="id") |
125
|
|
|
* }) |
126
|
|
|
*/ |
127
|
|
|
private $serie; |
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* @var Badge |
131
|
|
|
* |
132
|
|
|
* @ORM\ManyToOne(targetEntity="ProjetNormandie\BadgeBundle\Entity\Badge") |
133
|
|
|
* @ORM\JoinColumns({ |
134
|
|
|
* @ORM\JoinColumn(name="idBadge", referencedColumnName="idBadge") |
135
|
|
|
* }) |
136
|
|
|
*/ |
137
|
|
|
private $badge; |
138
|
|
|
|
139
|
|
|
/** |
140
|
|
|
* @ORM\OneToMany(targetEntity="VideoGamesRecords\CoreBundle\Entity\Group", mappedBy="game", cascade={"persist", "remove"}, orphanRemoval=true) |
141
|
|
|
*/ |
142
|
|
|
private $groups; |
143
|
|
|
|
144
|
|
|
/** |
145
|
|
|
* @ORM\ManyToMany(targetEntity="Platform") |
146
|
|
|
* @ORM\JoinTable(name="vgr_game_platform", |
147
|
|
|
* joinColumns={@ORM\JoinColumn(name="idGame", referencedColumnName="id")}, |
148
|
|
|
* inverseJoinColumns={@ORM\JoinColumn(name="idPlatform", referencedColumnName="idPlatform")} |
149
|
|
|
* ) |
150
|
|
|
* @ORM\OrderBy({"libPlatform" = "ASC"}) |
151
|
|
|
*/ |
152
|
|
|
private $platforms; |
153
|
|
|
|
154
|
|
|
/** |
155
|
|
|
* Constructor |
156
|
|
|
*/ |
157
|
|
|
public function __construct() |
158
|
|
|
{ |
159
|
|
|
$this->groups = new ArrayCollection(); |
160
|
|
|
$this->platforms = new ArrayCollection(); |
161
|
|
|
} |
162
|
|
|
|
163
|
|
|
/** |
164
|
|
|
* @return string |
165
|
|
|
*/ |
166
|
|
|
public function __toString() |
167
|
|
|
{ |
168
|
|
|
return sprintf('%s [%s]', $this->getName(), $this->id); |
169
|
|
|
} |
170
|
|
|
|
171
|
|
|
/** |
172
|
|
|
* Set id |
173
|
|
|
* |
174
|
|
|
* @param integer $id |
175
|
|
|
* @return Game |
176
|
|
|
*/ |
177
|
|
|
public function setId($id) |
178
|
|
|
{ |
179
|
|
|
$this->id = $id; |
180
|
|
|
return $this; |
181
|
|
|
} |
182
|
|
|
|
183
|
|
|
/** |
184
|
|
|
* Get id |
185
|
|
|
* |
186
|
|
|
* @return integer |
187
|
|
|
*/ |
188
|
|
|
public function getId() |
189
|
|
|
{ |
190
|
|
|
return $this->id; |
191
|
|
|
} |
192
|
|
|
|
193
|
|
|
/** |
194
|
|
|
* Get libGame |
195
|
|
|
* |
196
|
|
|
* @return string |
197
|
|
|
*/ |
198
|
|
|
public function getLibGame() |
199
|
|
|
{ |
200
|
|
|
return $this->getName(); |
201
|
|
|
} |
202
|
|
|
|
203
|
|
|
/** |
204
|
|
|
* @param string $name |
205
|
|
|
* @return $this |
206
|
|
|
*/ |
207
|
|
|
public function setName($name) |
208
|
|
|
{ |
209
|
|
|
$this->translate(null, false)->setName($name); |
210
|
|
|
|
211
|
|
|
return $this; |
212
|
|
|
} |
213
|
|
|
|
214
|
|
|
/** |
215
|
|
|
* @return string |
216
|
|
|
*/ |
217
|
|
|
public function getName() |
218
|
|
|
{ |
219
|
|
|
return $this->translate(null, false)->getName(); |
220
|
|
|
} |
221
|
|
|
|
222
|
|
|
/** |
223
|
|
|
* Set picture |
224
|
|
|
* |
225
|
|
|
* @param string $picture |
226
|
|
|
* @return Game |
227
|
|
|
*/ |
228
|
|
|
public function setPicture($picture) |
229
|
|
|
{ |
230
|
|
|
$this->picture = $picture; |
231
|
|
|
|
232
|
|
|
return $this; |
233
|
|
|
} |
234
|
|
|
|
235
|
|
|
/** |
236
|
|
|
* Get picture |
237
|
|
|
* |
238
|
|
|
* @return string |
239
|
|
|
*/ |
240
|
|
|
public function getPicture() |
241
|
|
|
{ |
242
|
|
|
return $this->picture; |
243
|
|
|
} |
244
|
|
|
|
245
|
|
|
/** |
246
|
|
|
* Set status |
247
|
|
|
* |
248
|
|
|
* @param string $status |
249
|
|
|
* @return Game |
250
|
|
|
*/ |
251
|
|
|
public function setStatus($status) |
252
|
|
|
{ |
253
|
|
|
$this->status = $status; |
254
|
|
|
|
255
|
|
|
return $this; |
256
|
|
|
} |
257
|
|
|
|
258
|
|
|
/** |
259
|
|
|
* Get status |
260
|
|
|
* |
261
|
|
|
* @return string |
262
|
|
|
*/ |
263
|
|
|
public function getStatus() |
264
|
|
|
{ |
265
|
|
|
return $this->status; |
266
|
|
|
} |
267
|
|
|
|
268
|
|
|
/** |
269
|
|
|
* Set etat |
270
|
|
|
* |
271
|
|
|
* @param string $etat |
272
|
|
|
* @return Game |
273
|
|
|
*/ |
274
|
|
|
public function setEtat($etat) |
275
|
|
|
{ |
276
|
|
|
$this->etat = $etat; |
277
|
|
|
|
278
|
|
|
return $this; |
279
|
|
|
} |
280
|
|
|
|
281
|
|
|
/** |
282
|
|
|
* Get etat |
283
|
|
|
* |
284
|
|
|
* @return string |
285
|
|
|
*/ |
286
|
|
|
public function getEtat() |
287
|
|
|
{ |
288
|
|
|
return $this->etat; |
289
|
|
|
} |
290
|
|
|
|
291
|
|
|
/** |
292
|
|
|
* Set dateActivation |
293
|
|
|
* |
294
|
|
|
* @param \DateTime $dateActivation |
295
|
|
|
* @return Game |
296
|
|
|
*/ |
297
|
|
|
public function setDateActivation($dateActivation) |
298
|
|
|
{ |
299
|
|
|
$this->dateActivation = $dateActivation; |
300
|
|
|
|
301
|
|
|
return $this; |
302
|
|
|
} |
303
|
|
|
|
304
|
|
|
/** |
305
|
|
|
* Get dateActivation |
306
|
|
|
* |
307
|
|
|
* @return \DateTime |
308
|
|
|
*/ |
309
|
|
|
public function getDateActivation() |
310
|
|
|
{ |
311
|
|
|
return $this->dateActivation; |
312
|
|
|
} |
313
|
|
|
|
314
|
|
|
/** |
315
|
|
|
* Set boolDlc |
316
|
|
|
* |
317
|
|
|
* @param boolean $boolDlc |
318
|
|
|
* @return Game |
319
|
|
|
*/ |
320
|
|
|
public function setBoolDlc($boolDlc) |
321
|
|
|
{ |
322
|
|
|
$this->boolDlc = $boolDlc; |
323
|
|
|
|
324
|
|
|
return $this; |
325
|
|
|
} |
326
|
|
|
|
327
|
|
|
/** |
328
|
|
|
* Get boolDlc |
329
|
|
|
* |
330
|
|
|
* @return boolean |
331
|
|
|
*/ |
332
|
|
|
public function getBoolDlc() |
333
|
|
|
{ |
334
|
|
|
return $this->boolDlc; |
335
|
|
|
} |
336
|
|
|
|
337
|
|
|
/** |
338
|
|
|
* Set nbChart |
339
|
|
|
* |
340
|
|
|
* @param integer $nbChart |
341
|
|
|
* @return Game |
342
|
|
|
*/ |
343
|
|
|
public function setNbChart($nbChart) |
344
|
|
|
{ |
345
|
|
|
$this->nbChart = $nbChart; |
346
|
|
|
|
347
|
|
|
return $this; |
348
|
|
|
} |
349
|
|
|
|
350
|
|
|
/** |
351
|
|
|
* Get nbChart |
352
|
|
|
* |
353
|
|
|
* @return integer |
354
|
|
|
*/ |
355
|
|
|
public function getNbChart() |
356
|
|
|
{ |
357
|
|
|
return $this->nbChart; |
358
|
|
|
} |
359
|
|
|
|
360
|
|
|
/** |
361
|
|
|
* Set nbPost |
362
|
|
|
* |
363
|
|
|
* @param integer $nbPost |
364
|
|
|
* @return Game |
365
|
|
|
*/ |
366
|
|
|
public function setNbPost($nbPost) |
367
|
|
|
{ |
368
|
|
|
$this->nbPost = $nbPost; |
369
|
|
|
|
370
|
|
|
return $this; |
371
|
|
|
} |
372
|
|
|
|
373
|
|
|
/** |
374
|
|
|
* Get nbPost |
375
|
|
|
* |
376
|
|
|
* @return integer |
377
|
|
|
*/ |
378
|
|
|
public function getNbPost() |
379
|
|
|
{ |
380
|
|
|
return $this->nbPost; |
381
|
|
|
} |
382
|
|
|
|
383
|
|
|
/** |
384
|
|
|
* Set nbPlayer |
385
|
|
|
* |
386
|
|
|
* @param integer $nbPlayer |
387
|
|
|
* @return Game |
388
|
|
|
*/ |
389
|
|
|
public function setNbPlayer($nbPlayer) |
390
|
|
|
{ |
391
|
|
|
$this->nbPlayer = $nbPlayer; |
392
|
|
|
|
393
|
|
|
return $this; |
394
|
|
|
} |
395
|
|
|
|
396
|
|
|
/** |
397
|
|
|
* Get nbPlayer |
398
|
|
|
* |
399
|
|
|
* @return integer |
400
|
|
|
*/ |
401
|
|
|
public function getNbPlayer() |
402
|
|
|
{ |
403
|
|
|
return $this->nbPlayer; |
404
|
|
|
} |
405
|
|
|
|
406
|
|
|
/** |
407
|
|
|
* Set nbTeam |
408
|
|
|
* |
409
|
|
|
* @param integer $nbTeam |
410
|
|
|
* @return Game |
411
|
|
|
*/ |
412
|
|
|
public function setNbTeam($nbTeam) |
413
|
|
|
{ |
414
|
|
|
$this->nbTeam = $nbTeam; |
415
|
|
|
|
416
|
|
|
return $this; |
417
|
|
|
} |
418
|
|
|
|
419
|
|
|
/** |
420
|
|
|
* Get nbTeam |
421
|
|
|
* |
422
|
|
|
* @return integer |
423
|
|
|
*/ |
424
|
|
|
public function getNbTeam() |
425
|
|
|
{ |
426
|
|
|
return $this->nbTeam; |
427
|
|
|
} |
428
|
|
|
|
429
|
|
|
/** |
430
|
|
|
* Set ordre |
431
|
|
|
* |
432
|
|
|
* @param integer $ordre |
433
|
|
|
* @return Game |
434
|
|
|
*/ |
435
|
|
|
public function setOrdre($ordre) |
436
|
|
|
{ |
437
|
|
|
$this->ordre = $ordre; |
438
|
|
|
|
439
|
|
|
return $this; |
440
|
|
|
} |
441
|
|
|
|
442
|
|
|
/** |
443
|
|
|
* Get ordre |
444
|
|
|
* |
445
|
|
|
* @return integer |
446
|
|
|
*/ |
447
|
|
|
public function getOrdre() |
448
|
|
|
{ |
449
|
|
|
return $this->ordre; |
450
|
|
|
} |
451
|
|
|
|
452
|
|
|
/** |
453
|
|
|
* Set serie |
454
|
|
|
* |
455
|
|
|
* @param Serie $serie |
456
|
|
|
* @return Game |
457
|
|
|
*/ |
458
|
|
|
public function setSerie(Serie $serie = null) |
459
|
|
|
{ |
460
|
|
|
$this->serie = $serie; |
461
|
|
|
|
462
|
|
|
return $this; |
463
|
|
|
} |
464
|
|
|
|
465
|
|
|
/** |
466
|
|
|
* Get idSerie |
467
|
|
|
* |
468
|
|
|
* @return Serie |
469
|
|
|
*/ |
470
|
|
|
public function getSerie() |
471
|
|
|
{ |
472
|
|
|
return $this->serie; |
473
|
|
|
} |
474
|
|
|
|
475
|
|
|
/** |
476
|
|
|
* Set badge |
477
|
|
|
* |
478
|
|
|
* @param Badge $badge |
479
|
|
|
* @return Game |
480
|
|
|
*/ |
481
|
|
|
public function setBadge(Badge $badge = null) |
482
|
|
|
{ |
483
|
|
|
$this->badge = $badge; |
484
|
|
|
|
485
|
|
|
return $this; |
486
|
|
|
} |
487
|
|
|
|
488
|
|
|
/** |
489
|
|
|
* Get idBadge |
490
|
|
|
* |
491
|
|
|
* @return Badge |
492
|
|
|
*/ |
493
|
|
|
public function getBadge() |
494
|
|
|
{ |
495
|
|
|
return $this->badge; |
496
|
|
|
} |
497
|
|
|
|
498
|
|
|
/** |
499
|
|
|
* @param Group $group |
500
|
|
|
* @return $this |
501
|
|
|
*/ |
502
|
|
|
public function addGroup(Group $group) |
503
|
|
|
{ |
504
|
|
|
$group->setGame($this); |
505
|
|
|
$this->groups[] = $group; |
506
|
|
|
return $this; |
507
|
|
|
} |
508
|
|
|
|
509
|
|
|
/** |
510
|
|
|
* @param Group $group |
511
|
|
|
*/ |
512
|
|
|
public function removeGroup(Group $group) |
513
|
|
|
{ |
514
|
|
|
$this->groups->removeElement($group); |
515
|
|
|
} |
516
|
|
|
|
517
|
|
|
/** |
518
|
|
|
* @return mixed |
519
|
|
|
*/ |
520
|
|
|
public function getGroups() |
521
|
|
|
{ |
522
|
|
|
return $this->groups; |
523
|
|
|
} |
524
|
|
|
|
525
|
|
|
|
526
|
|
|
/** |
527
|
|
|
* @param Platform $platform |
528
|
|
|
* @return $this |
529
|
|
|
*/ |
530
|
|
|
public function addPlatform(Platform $platform) |
531
|
|
|
{ |
532
|
|
|
$this->platforms[] = $platform; |
533
|
|
|
return $this; |
534
|
|
|
} |
535
|
|
|
|
536
|
|
|
/** |
537
|
|
|
* @param Platform $platform |
538
|
|
|
*/ |
539
|
|
|
public function removePlatform(Platform $platform) |
540
|
|
|
{ |
541
|
|
|
$this->groups->removeElement($platform); |
542
|
|
|
} |
543
|
|
|
|
544
|
|
|
/** |
545
|
|
|
* @return mixed |
546
|
|
|
*/ |
547
|
|
|
public function getPlatforms() |
548
|
|
|
{ |
549
|
|
|
return $this->platforms; |
550
|
|
|
} |
551
|
|
|
|
552
|
|
|
/** |
553
|
|
|
* @return array |
554
|
|
|
*/ |
555
|
|
|
public static function getStatusChoices() |
556
|
|
|
{ |
557
|
|
|
return [ |
558
|
|
|
self::STATUS_ACTIVE => self::STATUS_ACTIVE, |
559
|
|
|
self::STATUS_INACTIVE => self::STATUS_INACTIVE, |
560
|
|
|
]; |
561
|
|
|
} |
562
|
|
|
|
563
|
|
|
/** |
564
|
|
|
* @return array |
565
|
|
|
*/ |
566
|
|
|
public static function getEtatsChoices() |
567
|
|
|
{ |
568
|
|
|
return [ |
569
|
|
|
self::ETAT_INIT => self::ETAT_INIT, |
570
|
|
|
self::ETAT_CHART => self::ETAT_CHART, |
571
|
|
|
self::ETAT_PICTURE => self::ETAT_PICTURE, |
572
|
|
|
self::ETAT_END => self::ETAT_END, |
573
|
|
|
]; |
574
|
|
|
} |
575
|
|
|
|
576
|
|
|
/** |
577
|
|
|
* Returns an array of the fields used to generate the slug. |
578
|
|
|
* |
579
|
|
|
* @return array |
580
|
|
|
*/ |
581
|
|
|
public function getSluggableFields() |
582
|
|
|
{ |
583
|
|
|
return ['name']; |
584
|
|
|
} |
585
|
|
|
} |
586
|
|
|
|