1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace VideoGamesRecords\CoreBundle\Entity; |
6
|
|
|
|
7
|
|
|
use ApiPlatform\Metadata\ApiProperty; |
8
|
|
|
use ApiPlatform\Metadata\ApiResource; |
9
|
|
|
use ApiPlatform\Metadata\Get; |
10
|
|
|
use ApiPlatform\Metadata\GetCollection; |
11
|
|
|
use Doctrine\ORM\Mapping as ORM; |
12
|
|
|
use VideoGamesRecords\CoreBundle\Repository\PlayerGroupRepository; |
13
|
|
|
use VideoGamesRecords\CoreBundle\Traits\Entity\ChartRank0Trait; |
14
|
|
|
use VideoGamesRecords\CoreBundle\Traits\Entity\ChartRank1Trait; |
15
|
|
|
use VideoGamesRecords\CoreBundle\Traits\Entity\ChartRank2Trait; |
16
|
|
|
use VideoGamesRecords\CoreBundle\Traits\Entity\ChartRank3Trait; |
17
|
|
|
use VideoGamesRecords\CoreBundle\Traits\Entity\ChartRank4Trait; |
18
|
|
|
use VideoGamesRecords\CoreBundle\Traits\Entity\ChartRank5Trait; |
19
|
|
|
use VideoGamesRecords\CoreBundle\Traits\Entity\LastUpdateTrait; |
20
|
|
|
use VideoGamesRecords\CoreBundle\Traits\Entity\NbChartProvenTrait; |
21
|
|
|
use VideoGamesRecords\CoreBundle\Traits\Entity\NbChartTrait; |
22
|
|
|
use VideoGamesRecords\CoreBundle\Traits\Entity\PointChartTrait; |
23
|
|
|
use VideoGamesRecords\CoreBundle\Traits\Entity\RankMedalTrait; |
24
|
|
|
use VideoGamesRecords\CoreBundle\Traits\Entity\RankPointChartTrait; |
25
|
|
|
|
26
|
|
|
#[ORM\Table(name:'vgr_player_group')] |
27
|
|
|
#[ORM\Entity(repositoryClass: PlayerGroupRepository::class)] |
28
|
|
|
#[ApiResource( |
29
|
|
|
operations: [ |
30
|
|
|
new GetCollection(), |
31
|
|
|
new Get() |
32
|
|
|
], |
33
|
|
|
normalizationContext: ['groups' => ['player-group:read']] |
34
|
|
|
)] |
35
|
|
|
class PlayerGroup |
36
|
|
|
{ |
37
|
|
|
use NbChartTrait; |
38
|
|
|
use NbChartProvenTrait; |
39
|
|
|
use RankMedalTrait; |
40
|
|
|
use ChartRank0Trait; |
41
|
|
|
use ChartRank1Trait; |
42
|
|
|
use ChartRank2Trait; |
43
|
|
|
use ChartRank3Trait; |
44
|
|
|
use ChartRank4Trait; |
45
|
|
|
use ChartRank5Trait; |
46
|
|
|
use RankPointChartTrait; |
47
|
|
|
use PointChartTrait; |
48
|
|
|
use LastUpdateTrait; |
49
|
|
|
|
50
|
|
|
#[ApiProperty(identifier: false)] |
51
|
|
|
#[ORM\Id] |
52
|
|
|
#[ORM\ManyToOne(targetEntity: Player::class)] |
53
|
|
|
#[ORM\JoinColumn(name:'player_id', referencedColumnName:'id', nullable:false, onDelete:'CASCADE')] |
54
|
|
|
private Player $player; |
55
|
|
|
|
56
|
|
|
#[ApiProperty(identifier: false)] |
57
|
|
|
#[ORM\Id] |
58
|
|
|
#[ORM\ManyToOne(targetEntity: Group::class, fetch: 'EAGER')] |
59
|
|
|
#[ORM\JoinColumn(name:'group_id', referencedColumnName:'id', nullable:false, onDelete:'CASCADE')] |
60
|
|
|
private Group $group; |
61
|
|
|
|
62
|
|
|
public function setGroup(Group $group): void |
63
|
|
|
{ |
64
|
|
|
$this->group = $group; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
public function getGroup(): Group |
68
|
|
|
{ |
69
|
|
|
return $this->group; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
public function setPlayer(Player $player): void |
73
|
|
|
{ |
74
|
|
|
$this->player = $player; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
public function getPlayer(): Player |
78
|
|
|
{ |
79
|
|
|
return $this->player; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
#[ApiProperty(identifier: true)] |
83
|
|
|
public function getId(): string |
84
|
|
|
{ |
85
|
|
|
return sprintf('player=%d;group=%d', $this->player->getId(), $this->group->getId()); |
86
|
|
|
} |
87
|
|
|
} |
88
|
|
|
|