|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace VideoGamesRecords\CoreBundle\Entity; |
|
6
|
|
|
|
|
7
|
|
|
use ApiPlatform\Doctrine\Common\Filter\DateFilterInterface; |
|
8
|
|
|
use ApiPlatform\Metadata\ApiProperty; |
|
9
|
|
|
use ApiPlatform\Metadata\ApiResource; |
|
10
|
|
|
use ApiPlatform\Metadata\ApiFilter; |
|
11
|
|
|
use ApiPlatform\Doctrine\Orm\Filter\DateFilter; |
|
12
|
|
|
use ApiPlatform\Doctrine\Orm\Filter\OrderFilter; |
|
13
|
|
|
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter; |
|
14
|
|
|
use ApiPlatform\Metadata\Get; |
|
15
|
|
|
use ApiPlatform\Metadata\GetCollection; |
|
16
|
|
|
use ApiPlatform\Metadata\Link; |
|
17
|
|
|
use ApiPlatform\OpenApi\Model; |
|
18
|
|
|
use DateTime; |
|
19
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
|
20
|
|
|
use Doctrine\Common\Collections\Collection; |
|
21
|
|
|
use Doctrine\ORM\Mapping as ORM; |
|
22
|
|
|
use Gedmo\Timestampable\Traits\TimestampableEntity; |
|
23
|
|
|
use Gedmo\Mapping\Annotation as Gedmo; |
|
24
|
|
|
use Symfony\Component\Intl\Locale; |
|
25
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
|
26
|
|
|
use VideoGamesRecords\CoreBundle\Controller\Game\Autocomplete; |
|
27
|
|
|
use VideoGamesRecords\CoreBundle\Controller\Game\GetFormData; |
|
28
|
|
|
use VideoGamesRecords\CoreBundle\Controller\Game\GetGameOfDay; |
|
29
|
|
|
use VideoGamesRecords\CoreBundle\Controller\Game\GetListByLetter; |
|
30
|
|
|
use VideoGamesRecords\CoreBundle\Repository\GameRepository; |
|
31
|
|
|
use VideoGamesRecords\CoreBundle\Traits\Entity\IsRankTrait; |
|
32
|
|
|
use VideoGamesRecords\CoreBundle\Traits\Entity\LastUpdateTrait; |
|
33
|
|
|
use VideoGamesRecords\CoreBundle\Traits\Entity\NbChartTrait; |
|
34
|
|
|
use VideoGamesRecords\CoreBundle\Traits\Entity\NbPlayerTrait; |
|
35
|
|
|
use VideoGamesRecords\CoreBundle\Traits\Entity\NbPostTrait; |
|
36
|
|
|
use VideoGamesRecords\CoreBundle\Traits\Entity\NbTeamTrait; |
|
37
|
|
|
use VideoGamesRecords\CoreBundle\Traits\Entity\NbVideoTrait; |
|
38
|
|
|
use VideoGamesRecords\CoreBundle\Traits\Entity\PictureTrait; |
|
39
|
|
|
use VideoGamesRecords\CoreBundle\ValueObject\GameStatus; |
|
40
|
|
|
use VideoGamesRecords\IgdbBundle\Entity\Game as IgdbGame; |
|
41
|
|
|
use VideoGamesRecords\CoreBundle\Controller\Game\Player\GetRankingPoints as PlayerGetRankingPoints; |
|
42
|
|
|
use VideoGamesRecords\CoreBundle\Controller\Game\Player\GetRankingMedals as PlayerGetRankingMedals; |
|
43
|
|
|
use VideoGamesRecords\CoreBundle\Controller\Game\Team\GetRankingPoints as TeamGetRankingPoints; |
|
44
|
|
|
use VideoGamesRecords\CoreBundle\Controller\Game\Team\GetRankingPoints as TeamGetRankingMedals; |
|
45
|
|
|
use VideoGamesRecords\CoreBundle\Filter\GameSearchFilter; |
|
46
|
|
|
use VideoGamesRecords\IgdbBundle\Contract\GameInfoInterface; |
|
47
|
|
|
|
|
48
|
|
|
#[ORM\Table(name:'vgr_game')] |
|
49
|
|
|
#[ORM\Entity(repositoryClass: GameRepository::class)] |
|
50
|
|
|
#[ORM\EntityListeners(["VideoGamesRecords\CoreBundle\EventListener\Entity\GameListener"])] |
|
51
|
|
|
#[ORM\Index(name: "idx_lib_game_fr", columns: ["lib_game_fr"])] |
|
52
|
|
|
#[ORM\Index(name: "idx_lib_game_en", columns: ["lib_game_en"])] |
|
53
|
|
|
#[ORM\Index(name: "status", columns: ["status"])] |
|
54
|
|
|
#[ApiResource( |
|
55
|
|
|
operations: [ |
|
56
|
|
|
new GetCollection(), |
|
57
|
|
|
new GetCollection( |
|
58
|
|
|
uriTemplate: '/games/list-by-letter', |
|
59
|
|
|
controller: GetListByLetter::class, |
|
60
|
|
|
openapi: new Model\Operation( |
|
61
|
|
|
summary: 'Retrieves games by letter', |
|
62
|
|
|
description: 'Retrieves games by letter', |
|
63
|
|
|
parameters: [ |
|
64
|
|
|
new Model\Parameter( |
|
65
|
|
|
name: 'letter', |
|
66
|
|
|
in: 'query', |
|
67
|
|
|
required: true, |
|
68
|
|
|
schema: [ |
|
69
|
|
|
'type' => 'string', |
|
70
|
|
|
'pattern' => '[a-zA-Z0]' |
|
71
|
|
|
] |
|
72
|
|
|
) |
|
73
|
|
|
] |
|
74
|
|
|
), |
|
75
|
|
|
paginationEnabled: false, |
|
76
|
|
|
normalizationContext: ['groups' => [ |
|
77
|
|
|
'game:read', 'game:platforms', 'platform:read'] |
|
78
|
|
|
], |
|
79
|
|
|
), |
|
80
|
|
|
new GetCollection( |
|
81
|
|
|
uriTemplate: '/games/autocomplete', |
|
82
|
|
|
controller: Autocomplete::class, |
|
83
|
|
|
normalizationContext: ['groups' => [ |
|
84
|
|
|
'game:read'] |
|
85
|
|
|
], |
|
86
|
|
|
openapi: new Model\Operation( |
|
87
|
|
|
summary: 'Retrieves games by autocompletion', |
|
88
|
|
|
description: 'Retrieves games by autocompletion' |
|
89
|
|
|
), |
|
90
|
|
|
/*openapiContext: [ |
|
91
|
|
|
'parameters' => [ |
|
92
|
|
|
[ |
|
93
|
|
|
'name' => 'query', |
|
94
|
|
|
'in' => 'query', |
|
95
|
|
|
'type' => 'string', |
|
96
|
|
|
'required' => true |
|
97
|
|
|
] |
|
98
|
|
|
] |
|
99
|
|
|
]*/ |
|
100
|
|
|
), |
|
101
|
|
|
new GetCollection( |
|
102
|
|
|
uriTemplate: '/games/game-of-day', |
|
103
|
|
|
controller: GetGameOfDay::class, |
|
104
|
|
|
normalizationContext: ['groups' => [ |
|
105
|
|
|
'game:read', 'game:platforms', 'platform:read'] |
|
106
|
|
|
], |
|
107
|
|
|
), |
|
108
|
|
|
new Get( |
|
109
|
|
|
normalizationContext: ['groups' => [ |
|
110
|
|
|
'game:read', |
|
111
|
|
|
'game:platforms', 'platform:read', |
|
112
|
|
|
'game:discords', 'discord:read', |
|
113
|
|
|
'game:serie', 'serie:read', |
|
114
|
|
|
'game:rules', 'rule:read', |
|
115
|
|
|
'game:forum', 'forum:read', |
|
116
|
|
|
'game:igdb-game', 'igdb-game:read', |
|
117
|
|
|
'game:genres', 'igdb-genre:read' |
|
118
|
|
|
] |
|
119
|
|
|
] |
|
120
|
|
|
), |
|
121
|
|
|
new Get( |
|
122
|
|
|
uriTemplate: '/games/{id}/form-data', |
|
123
|
|
|
controller: GetFormData::class, |
|
124
|
|
|
security: "is_granted('ROLE_PLAYER')", |
|
125
|
|
|
normalizationContext: ['groups' => [ |
|
126
|
|
|
'chart:read', 'chart:libs', 'chart-lib:read', |
|
127
|
|
|
'chart-lib:type', 'chart-type:read', |
|
128
|
|
|
'chart:group', 'group:read', |
|
129
|
|
|
'chart:player-charts', 'player-chart:read', 'player-chart:chart', |
|
130
|
|
|
'player-chart:libs', 'player-chart-lib:read', |
|
131
|
|
|
'player-chart:player', 'player-chart:platform', |
|
132
|
|
|
'player-chart:status', 'player-chart-status:read'] |
|
133
|
|
|
], |
|
134
|
|
|
openapi: new Model\Operation( |
|
135
|
|
|
summary: 'Fetch game form data', |
|
136
|
|
|
description: 'Fetch game form data' |
|
137
|
|
|
), |
|
138
|
|
|
/*openapiContext: [ |
|
139
|
|
|
'parameters' => [ |
|
140
|
|
|
[ |
|
141
|
|
|
'name' => 'term', |
|
142
|
|
|
'in' => 'query', |
|
143
|
|
|
'type' => 'string', |
|
144
|
|
|
'required' => false |
|
145
|
|
|
] |
|
146
|
|
|
] |
|
147
|
|
|
]*/ |
|
148
|
|
|
), |
|
149
|
|
|
new Get( |
|
150
|
|
|
uriTemplate: '/games/{id}/player-ranking-points', |
|
151
|
|
|
controller: PlayerGetRankingPoints::class, |
|
152
|
|
|
normalizationContext: ['groups' => [ |
|
153
|
|
|
'player-game:read', |
|
154
|
|
|
'player-game:player', 'player:read:minimal', |
|
155
|
|
|
'player:team', 'team:read:minimal', |
|
156
|
|
|
'player:country', 'country:read'] |
|
157
|
|
|
], |
|
158
|
|
|
openapi: new Model\Operation( |
|
159
|
|
|
summary: 'Retrieves the player points leaderboard', |
|
160
|
|
|
description: 'Retrieves the player points leaderboard' |
|
161
|
|
|
), |
|
162
|
|
|
/*openapiContext: [ |
|
163
|
|
|
'parameters' => [ |
|
164
|
|
|
[ |
|
165
|
|
|
'name' => 'maxRank', |
|
166
|
|
|
'in' => 'query', |
|
167
|
|
|
'type' => 'integer', |
|
168
|
|
|
'required' => false |
|
169
|
|
|
] |
|
170
|
|
|
] |
|
171
|
|
|
]*/ |
|
172
|
|
|
), |
|
173
|
|
|
new Get( |
|
174
|
|
|
uriTemplate: '/games/{id}/player-ranking-medals', |
|
175
|
|
|
controller: PlayerGetRankingMedals::class, |
|
176
|
|
|
normalizationContext: ['groups' => [ |
|
177
|
|
|
'player-game:read', |
|
178
|
|
|
'player-game:player', 'player:read', |
|
179
|
|
|
'player:team', 'team:read:minimal', |
|
180
|
|
|
'player:country', 'country:read'] |
|
181
|
|
|
], |
|
182
|
|
|
openapi: new Model\Operation( |
|
183
|
|
|
summary: 'Retrieves the player medals leaderboard', |
|
184
|
|
|
description: 'Retrieves the player medals leaderboard' |
|
185
|
|
|
), |
|
186
|
|
|
/*openapiContext: [ |
|
187
|
|
|
'parameters' => [ |
|
188
|
|
|
[ |
|
189
|
|
|
'name' => 'maxRank', |
|
190
|
|
|
'in' => 'query', |
|
191
|
|
|
'type' => 'integer', |
|
192
|
|
|
'required' => false |
|
193
|
|
|
] |
|
194
|
|
|
] |
|
195
|
|
|
]*/ |
|
196
|
|
|
), |
|
197
|
|
|
new Get( |
|
198
|
|
|
uriTemplate: '/games/{id}/team-ranking-points', |
|
199
|
|
|
controller: TeamGetRankingPoints::class, |
|
200
|
|
|
normalizationContext: ['groups' => [ |
|
201
|
|
|
'team-game:read', |
|
202
|
|
|
'team-game:team', 'team:read:minimal'] |
|
203
|
|
|
], |
|
204
|
|
|
openapi: new Model\Operation( |
|
205
|
|
|
summary: 'Retrieves the team points leaderboard', |
|
206
|
|
|
description: 'Retrieves the team points leaderboard' |
|
207
|
|
|
), |
|
208
|
|
|
/*openapiContext: [ |
|
209
|
|
|
'parameters' => [ |
|
210
|
|
|
[ |
|
211
|
|
|
'name' => 'maxRank', |
|
212
|
|
|
'in' => 'query', |
|
213
|
|
|
'type' => 'integer', |
|
214
|
|
|
'required' => false |
|
215
|
|
|
] |
|
216
|
|
|
] |
|
217
|
|
|
]*/ |
|
218
|
|
|
), |
|
219
|
|
|
new Get( |
|
220
|
|
|
uriTemplate: '/games/{id}/team-ranking-medals', |
|
221
|
|
|
controller: TeamGetRankingMedals::class, |
|
222
|
|
|
normalizationContext: ['groups' => [ |
|
223
|
|
|
'team-game:read', |
|
224
|
|
|
'team-game:team', 'team:read:minimal'] |
|
225
|
|
|
], |
|
226
|
|
|
openapi: new Model\Operation( |
|
227
|
|
|
summary: 'Retrieves the team medals leaderboard', |
|
228
|
|
|
description: 'Retrieves the team medals leaderboard' |
|
229
|
|
|
), |
|
230
|
|
|
/*openapiContext: [ |
|
231
|
|
|
'parameters' => [ |
|
232
|
|
|
[ |
|
233
|
|
|
'name' => 'maxRank', |
|
234
|
|
|
'in' => 'query', |
|
235
|
|
|
'type' => 'integer', |
|
236
|
|
|
'required' => false |
|
237
|
|
|
] |
|
238
|
|
|
] |
|
239
|
|
|
]*/ |
|
240
|
|
|
), |
|
241
|
|
|
], |
|
242
|
|
|
normalizationContext: ['groups' => ['game:read', 'game:platforms', 'platform:read', 'game:genres', 'igdb-genre:read']], |
|
243
|
|
|
)] |
|
244
|
|
|
#[ApiResource( |
|
245
|
|
|
uriTemplate: '/platforms/{id}/games', |
|
246
|
|
|
uriVariables: [ |
|
247
|
|
|
'id' => new Link(fromClass: Platform::class, toProperty: 'platforms'), |
|
248
|
|
|
], |
|
249
|
|
|
operations: [ new GetCollection() ], |
|
250
|
|
|
normalizationContext: ['groups' => ['game:read']], |
|
251
|
|
|
)] |
|
252
|
|
|
#[ApiResource( |
|
253
|
|
|
uriTemplate: '/series/{id}/games', |
|
254
|
|
|
uriVariables: [ |
|
255
|
|
|
'id' => new Link(fromClass: Serie::class, toProperty: 'serie'), |
|
256
|
|
|
], |
|
257
|
|
|
operations: [ new GetCollection() ], |
|
258
|
|
|
normalizationContext: ['groups' => ['game:read', 'game:platforms', 'platform:read']], |
|
259
|
|
|
)] |
|
260
|
|
|
#[ApiFilter( |
|
261
|
|
|
SearchFilter::class, |
|
262
|
|
|
properties: [ |
|
263
|
|
|
'id' => 'exact', |
|
264
|
|
|
'status' => 'exact', |
|
265
|
|
|
'platforms' => 'exact', |
|
266
|
|
|
'playerGame.player' => 'exact', |
|
267
|
|
|
'groups.charts.lostPositions.player' => 'exact', |
|
268
|
|
|
'libGameEn' => 'partial', |
|
269
|
|
|
'libGameFr' => 'partial', |
|
270
|
|
|
'badge' => 'exact', |
|
271
|
|
|
'serie' => 'exact', |
|
272
|
|
|
'type' => 'exact', |
|
273
|
|
|
] |
|
274
|
|
|
)] |
|
275
|
|
|
#[ApiFilter( |
|
276
|
|
|
OrderFilter::class, |
|
277
|
|
|
properties: [ |
|
278
|
|
|
'id' => 'ASC', |
|
279
|
|
|
'libGameEn' => 'ASC', |
|
280
|
|
|
'libGameFr' => 'ASC', |
|
281
|
|
|
'publishedAt' => 'DESC', |
|
282
|
|
|
'nbChart' => 'DESC', |
|
283
|
|
|
'nbPost' => 'DESC', |
|
284
|
|
|
'nbPlayer' => 'DESC', |
|
285
|
|
|
'nbVideo' => 'DESC', |
|
286
|
|
|
'lastUpdate' => 'DESC', |
|
287
|
|
|
] |
|
288
|
|
|
)] |
|
289
|
|
|
#[ApiFilter(DateFilter::class, properties: ['publishedAt' => DateFilterInterface::INCLUDE_NULL_BEFORE_AND_AFTER])] |
|
290
|
|
|
#[ApiFilter(GameSearchFilter::class)] |
|
291
|
|
|
class Game implements GameInfoInterface |
|
292
|
|
|
{ |
|
293
|
|
|
use TimestampableEntity; |
|
294
|
|
|
use NbChartTrait; |
|
295
|
|
|
use NbPostTrait; |
|
296
|
|
|
use NbPlayerTrait; |
|
297
|
|
|
use NbTeamTrait; |
|
298
|
|
|
use PictureTrait; |
|
299
|
|
|
use NbVideoTrait; |
|
300
|
|
|
use IsRankTrait; |
|
301
|
|
|
use LastUpdateTrait; |
|
302
|
|
|
|
|
303
|
|
|
#[ApiProperty(identifier: true)] |
|
304
|
|
|
#[ORM\Id, ORM\Column, ORM\GeneratedValue] |
|
305
|
|
|
protected ?int $id = null; |
|
306
|
|
|
|
|
307
|
|
|
#[Assert\Length(max: 255)] |
|
308
|
|
|
#[ORM\Column(length: 255, nullable: false)] |
|
309
|
|
|
private string $libGameEn = ''; |
|
310
|
|
|
|
|
311
|
|
|
#[Assert\Length(max: 255)] |
|
312
|
|
|
#[ORM\Column(length: 255, nullable: false)] |
|
313
|
|
|
private string $libGameFr = ''; |
|
314
|
|
|
|
|
315
|
|
|
#[Assert\Length(max: 255)] |
|
316
|
|
|
#[ORM\Column(length: 255, nullable: true)] |
|
317
|
|
|
private ?string $downloadUrl; |
|
318
|
|
|
|
|
319
|
|
|
#[ORM\Column(length: 30, nullable: false, options: ['default' => GameStatus::CREATED])] |
|
320
|
|
|
private string $status = GameStatus::CREATED; |
|
321
|
|
|
|
|
322
|
|
|
#[ORM\Column(nullable: true)] |
|
323
|
|
|
private ?DateTime $publishedAt = null; |
|
324
|
|
|
|
|
325
|
|
|
#[ORM\ManyToOne(targetEntity: IgdbGame::class)] |
|
326
|
|
|
#[ORM\JoinColumn(name:'igdb_game_id', referencedColumnName:'id', nullable:true)] |
|
327
|
|
|
private ?IgdbGame $igdbGame = null; |
|
328
|
|
|
|
|
329
|
|
|
#[ORM\ManyToOne(targetEntity: Serie::class, inversedBy: 'games')] |
|
330
|
|
|
#[ORM\JoinColumn(name:'serie_id', referencedColumnName:'id', nullable:true)] |
|
331
|
|
|
private ?Serie $serie = null; |
|
332
|
|
|
|
|
333
|
|
|
|
|
334
|
|
|
#[ORM\OneToOne(targetEntity: Badge::class, cascade: ['persist'], inversedBy: 'game')] |
|
335
|
|
|
#[ORM\JoinColumn(name:'badge_id', referencedColumnName:'id', nullable:true)] |
|
336
|
|
|
private ?Badge $badge = null; |
|
337
|
|
|
|
|
338
|
|
|
/** |
|
339
|
|
|
* @var Collection<int, Group> |
|
340
|
|
|
*/ |
|
341
|
|
|
#[ORM\OneToMany(targetEntity: Group::class, cascade:['persist', 'remove'], mappedBy: 'game', orphanRemoval: true)] |
|
342
|
|
|
private Collection $groups; |
|
343
|
|
|
|
|
344
|
|
|
/** |
|
345
|
|
|
* @var Collection<int, Platform> |
|
346
|
|
|
*/ |
|
347
|
|
|
#[ORM\JoinTable(name: 'vgr_game_platform')] |
|
348
|
|
|
#[ORM\JoinColumn(name: 'game_id', referencedColumnName: 'id')] |
|
349
|
|
|
#[ORM\InverseJoinColumn(name: 'platform_id', referencedColumnName: 'id')] |
|
350
|
|
|
#[ORM\ManyToMany(targetEntity: Platform::class, inversedBy: 'games')] |
|
351
|
|
|
private Collection $platforms; |
|
352
|
|
|
|
|
353
|
|
|
#[ORM\OneToOne(targetEntity: ForumInterface::class, cascade: ['persist'])] |
|
354
|
|
|
#[ORM\JoinColumn(name:'forum_id', referencedColumnName:'id', nullable:true)] |
|
355
|
|
|
private $forum; |
|
356
|
|
|
|
|
357
|
|
|
#[ORM\OneToOne(targetEntity: PlayerChart::class)] |
|
358
|
|
|
#[ORM\JoinColumn(name:'last_score_id', referencedColumnName:'id', nullable:true)] |
|
359
|
|
|
private ?PlayerChart $lastScore; |
|
360
|
|
|
|
|
361
|
|
|
#[ORM\Column(length: 255)] |
|
362
|
|
|
#[Gedmo\Slug(fields: ['libGameEn'])] |
|
363
|
|
|
protected string $slug; |
|
364
|
|
|
|
|
365
|
|
|
/** |
|
366
|
|
|
* @var Collection<int, Rule> |
|
367
|
|
|
*/ |
|
368
|
|
|
#[ORM\ManyToMany(targetEntity: Rule::class, inversedBy: 'games')] |
|
369
|
|
|
#[ORM\JoinTable(name: 'vgr_rule_game')] |
|
370
|
|
|
private Collection $rules; |
|
371
|
|
|
|
|
372
|
|
|
/** |
|
373
|
|
|
* @var Collection<int, PlayerGame> |
|
374
|
|
|
*/ |
|
375
|
|
|
#[ORM\OneToMany(targetEntity: PlayerGame::class, mappedBy: 'game')] |
|
376
|
|
|
private Collection $playerGame; |
|
377
|
|
|
|
|
378
|
|
|
/** |
|
379
|
|
|
* @var Collection<int, TeamGame> |
|
380
|
|
|
*/ |
|
381
|
|
|
#[ORM\OneToMany(targetEntity: TeamGame::class, mappedBy: 'game')] |
|
382
|
|
|
private Collection $teamGame; |
|
383
|
|
|
|
|
384
|
|
|
/** |
|
385
|
|
|
* @var Collection<int, Discord> |
|
386
|
|
|
*/ |
|
387
|
|
|
#[ORM\ManyToMany(targetEntity: Discord::class, mappedBy: 'games')] |
|
388
|
|
|
private Collection $discords; |
|
389
|
|
|
|
|
390
|
|
|
|
|
391
|
|
|
public function __construct() |
|
392
|
|
|
{ |
|
393
|
|
|
$this->groups = new ArrayCollection(); |
|
394
|
|
|
$this->platforms = new ArrayCollection(); |
|
395
|
|
|
$this->rules = new ArrayCollection(); |
|
396
|
|
|
$this->playerGame = new ArrayCollection(); |
|
397
|
|
|
$this->teamGame = new ArrayCollection(); |
|
398
|
|
|
$this->discords = new ArrayCollection(); |
|
399
|
|
|
} |
|
400
|
|
|
|
|
401
|
|
|
public function __toString() |
|
402
|
|
|
{ |
|
403
|
|
|
return sprintf('%s (%d)', $this->getName(), $this->getId()); |
|
404
|
|
|
} |
|
405
|
|
|
|
|
406
|
|
|
public function getDefaultName(): string |
|
407
|
|
|
{ |
|
408
|
|
|
return $this->libGameEn; |
|
409
|
|
|
} |
|
410
|
|
|
|
|
411
|
|
|
public function getName(?string $locale = null): string |
|
412
|
|
|
{ |
|
413
|
|
|
if ($locale === null) { |
|
414
|
|
|
$locale = Locale::getDefault(); |
|
415
|
|
|
} |
|
416
|
|
|
if ($locale == 'fr') { |
|
417
|
|
|
return $this->libGameFr; |
|
418
|
|
|
} else { |
|
419
|
|
|
return $this->libGameEn; |
|
420
|
|
|
} |
|
421
|
|
|
} |
|
422
|
|
|
|
|
423
|
|
|
public function setId(int $id): void |
|
424
|
|
|
{ |
|
425
|
|
|
$this->id = $id; |
|
426
|
|
|
} |
|
427
|
|
|
|
|
428
|
|
|
public function getId(): ?int |
|
429
|
|
|
{ |
|
430
|
|
|
return $this->id; |
|
431
|
|
|
} |
|
432
|
|
|
|
|
433
|
|
|
public function setLibGameEn(string $libGameEn): void |
|
434
|
|
|
{ |
|
435
|
|
|
$this->libGameEn = $libGameEn; |
|
436
|
|
|
} |
|
437
|
|
|
|
|
438
|
|
|
public function getLibGameEn(): string |
|
439
|
|
|
{ |
|
440
|
|
|
return $this->libGameEn; |
|
441
|
|
|
} |
|
442
|
|
|
|
|
443
|
|
|
public function setLibGameFr(?string $libGameFr): void |
|
444
|
|
|
{ |
|
445
|
|
|
if ($libGameFr) { |
|
446
|
|
|
$this->libGameFr = $libGameFr; |
|
447
|
|
|
} |
|
448
|
|
|
} |
|
449
|
|
|
|
|
450
|
|
|
public function getLibGameFr(): string |
|
451
|
|
|
{ |
|
452
|
|
|
return $this->libGameFr; |
|
453
|
|
|
} |
|
454
|
|
|
|
|
455
|
|
|
public function setDownloadurl(?string $downloadUrl = null): void |
|
456
|
|
|
{ |
|
457
|
|
|
$this->downloadUrl = $downloadUrl; |
|
458
|
|
|
} |
|
459
|
|
|
|
|
460
|
|
|
public function getDownloadUrl(): ?string |
|
461
|
|
|
{ |
|
462
|
|
|
return $this->downloadUrl; |
|
463
|
|
|
} |
|
464
|
|
|
|
|
465
|
|
|
public function setStatus(string $status): void |
|
466
|
|
|
{ |
|
467
|
|
|
$this->status = $status; |
|
468
|
|
|
} |
|
469
|
|
|
|
|
470
|
|
|
public function getStatus(): string |
|
471
|
|
|
{ |
|
472
|
|
|
return $this->status; |
|
473
|
|
|
} |
|
474
|
|
|
|
|
475
|
|
|
public function getGameStatus(): GameStatus |
|
476
|
|
|
{ |
|
477
|
|
|
return new GameStatus($this->status); |
|
478
|
|
|
} |
|
479
|
|
|
|
|
480
|
|
|
public function getStatusAsString(): string |
|
481
|
|
|
{ |
|
482
|
|
|
return $this->status; |
|
483
|
|
|
} |
|
484
|
|
|
|
|
485
|
|
|
public function setPublishedAt(?DateTime $pubishedAt = null): void |
|
486
|
|
|
{ |
|
487
|
|
|
$this->publishedAt = $pubishedAt; |
|
488
|
|
|
} |
|
489
|
|
|
|
|
490
|
|
|
public function getPublishedAt(): ?DateTime |
|
491
|
|
|
{ |
|
492
|
|
|
return $this->publishedAt; |
|
493
|
|
|
} |
|
494
|
|
|
|
|
495
|
|
|
public function setIgdbGame(?IgdbGame $igdbGame): void |
|
496
|
|
|
{ |
|
497
|
|
|
$this->igdbGame = $igdbGame; |
|
498
|
|
|
} |
|
499
|
|
|
|
|
500
|
|
|
public function getIgdbGame(): ?IgdbGame |
|
501
|
|
|
{ |
|
502
|
|
|
return $this->igdbGame; |
|
503
|
|
|
} |
|
504
|
|
|
|
|
505
|
|
|
public function getIgdbId(): ?int |
|
506
|
|
|
{ |
|
507
|
|
|
return $this->igdbGame?->getId(); |
|
508
|
|
|
} |
|
509
|
|
|
|
|
510
|
|
|
public function setSerie(?Serie $serie = null): void |
|
511
|
|
|
{ |
|
512
|
|
|
$this->serie = $serie; |
|
513
|
|
|
} |
|
514
|
|
|
|
|
515
|
|
|
public function getSerie(): ?Serie |
|
516
|
|
|
{ |
|
517
|
|
|
return $this->serie; |
|
518
|
|
|
} |
|
519
|
|
|
|
|
520
|
|
|
public function setBadge($badge = null): void |
|
521
|
|
|
{ |
|
522
|
|
|
$this->badge = $badge; |
|
523
|
|
|
} |
|
524
|
|
|
|
|
525
|
|
|
public function getBadge(): ?Badge |
|
526
|
|
|
{ |
|
527
|
|
|
return $this->badge; |
|
528
|
|
|
} |
|
529
|
|
|
|
|
530
|
|
|
public function addGroup(Group $group): void |
|
531
|
|
|
{ |
|
532
|
|
|
$group->setGame($this); |
|
533
|
|
|
$this->groups[] = $group; |
|
534
|
|
|
} |
|
535
|
|
|
|
|
536
|
|
|
public function removeGroup(Group $group): void |
|
537
|
|
|
{ |
|
538
|
|
|
$this->groups->removeElement($group); |
|
539
|
|
|
} |
|
540
|
|
|
|
|
541
|
|
|
public function getGroups(): Collection |
|
542
|
|
|
{ |
|
543
|
|
|
return $this->groups; |
|
544
|
|
|
} |
|
545
|
|
|
|
|
546
|
|
|
public function addPlatform(Platform $platform): void |
|
547
|
|
|
{ |
|
548
|
|
|
$this->platforms[] = $platform; |
|
549
|
|
|
} |
|
550
|
|
|
|
|
551
|
|
|
public function removePlatform(Platform $platform): void |
|
552
|
|
|
{ |
|
553
|
|
|
$this->platforms->removeElement($platform); |
|
554
|
|
|
} |
|
555
|
|
|
|
|
556
|
|
|
public function getPlatforms(): ArrayCollection|Collection |
|
557
|
|
|
{ |
|
558
|
|
|
return $this->platforms; |
|
559
|
|
|
} |
|
560
|
|
|
|
|
561
|
|
|
public function getForum() |
|
562
|
|
|
{ |
|
563
|
|
|
return $this->forum; |
|
564
|
|
|
} |
|
565
|
|
|
|
|
566
|
|
|
public function setForum($forum): void |
|
567
|
|
|
{ |
|
568
|
|
|
$this->forum = $forum; |
|
569
|
|
|
} |
|
570
|
|
|
|
|
571
|
|
|
public function getLastScore(): ?PlayerChart |
|
572
|
|
|
{ |
|
573
|
|
|
return $this->lastScore; |
|
574
|
|
|
} |
|
575
|
|
|
|
|
576
|
|
|
public function setLastScore(?PlayerChart $lastScore): void |
|
577
|
|
|
{ |
|
578
|
|
|
$this->lastScore = $lastScore; |
|
579
|
|
|
} |
|
580
|
|
|
|
|
581
|
|
|
public function getSlug(): string |
|
582
|
|
|
{ |
|
583
|
|
|
return $this->slug; |
|
584
|
|
|
} |
|
585
|
|
|
|
|
586
|
|
|
public function getUrl(): string |
|
587
|
|
|
{ |
|
588
|
|
|
return sprintf( |
|
589
|
|
|
'%s-game-g%d/index', |
|
590
|
|
|
$this->getSlug(), |
|
591
|
|
|
$this->getId() |
|
592
|
|
|
); |
|
593
|
|
|
} |
|
594
|
|
|
|
|
595
|
|
|
public function addRule(Rule $rule): void |
|
596
|
|
|
{ |
|
597
|
|
|
$this->rules[] = $rule; |
|
598
|
|
|
} |
|
599
|
|
|
|
|
600
|
|
|
public function removeRule(Rule $rule): void |
|
601
|
|
|
{ |
|
602
|
|
|
$this->rules->removeElement($rule); |
|
603
|
|
|
} |
|
604
|
|
|
|
|
605
|
|
|
public function getPlayerGame(): Collection |
|
606
|
|
|
{ |
|
607
|
|
|
return $this->playerGame; |
|
608
|
|
|
} |
|
609
|
|
|
|
|
610
|
|
|
public function getTeamGame(): Collection |
|
611
|
|
|
{ |
|
612
|
|
|
return $this->teamGame; |
|
613
|
|
|
} |
|
614
|
|
|
|
|
615
|
|
|
public function getRules(): Collection |
|
616
|
|
|
{ |
|
617
|
|
|
return $this->rules; |
|
618
|
|
|
} |
|
619
|
|
|
|
|
620
|
|
|
/** |
|
621
|
|
|
* @return Collection<int, Discord> |
|
622
|
|
|
*/ |
|
623
|
|
|
public function getDiscords(): Collection |
|
624
|
|
|
{ |
|
625
|
|
|
return $this->discords; |
|
626
|
|
|
} |
|
627
|
|
|
|
|
628
|
|
|
public function addDiscord(Discord $discord): void |
|
629
|
|
|
{ |
|
630
|
|
|
if (!$this->discords->contains($discord)) { |
|
631
|
|
|
$this->discords->add($discord); |
|
632
|
|
|
$discord->addGame($this); |
|
633
|
|
|
} |
|
634
|
|
|
} |
|
635
|
|
|
|
|
636
|
|
|
public function removeDiscord(Discord $discord): void |
|
637
|
|
|
{ |
|
638
|
|
|
if ($this->discords->removeElement($discord)) { |
|
639
|
|
|
$discord->removeGame($this); |
|
640
|
|
|
} |
|
641
|
|
|
} |
|
642
|
|
|
|
|
643
|
|
|
public function getGenres(): Collection |
|
644
|
|
|
{ |
|
645
|
|
|
return $this->igdbGame?->getGenres() ?? new ArrayCollection(); |
|
646
|
|
|
} |
|
647
|
|
|
|
|
648
|
|
|
public function getReleaseDate(): ?DateTime |
|
649
|
|
|
{ |
|
650
|
|
|
$timestamp = $this->igdbGame?->getFirstReleaseDate(); |
|
651
|
|
|
if ($timestamp === null) { |
|
652
|
|
|
return null; |
|
653
|
|
|
} |
|
654
|
|
|
|
|
655
|
|
|
try { |
|
656
|
|
|
return new DateTime('@' . $timestamp); |
|
657
|
|
|
} catch (\Exception) { |
|
658
|
|
|
return null; |
|
659
|
|
|
} |
|
660
|
|
|
} |
|
661
|
|
|
|
|
662
|
|
|
public function getSummary(): ?string |
|
663
|
|
|
{ |
|
664
|
|
|
return $this->igdbGame?->getSummary(); |
|
665
|
|
|
} |
|
666
|
|
|
|
|
667
|
|
|
public function getStoryline(): ?string |
|
668
|
|
|
{ |
|
669
|
|
|
return $this->igdbGame?->getStoryline(); |
|
670
|
|
|
} |
|
671
|
|
|
} |
|
672
|
|
|
|