1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Obblm\Core\Entity; |
4
|
|
|
|
5
|
|
|
use Obblm\Core\Entity\Traits\DeadAndFireTrait; |
6
|
|
|
use Obblm\Core\Entity\Traits\NameTrait; |
7
|
|
|
use Obblm\Core\Repository\PlayerRepository; |
8
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
9
|
|
|
use Doctrine\Common\Collections\Collection; |
10
|
|
|
use Doctrine\ORM\Mapping as ORM; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* @ORM\Entity(repositoryClass=PlayerRepository::class) |
14
|
|
|
* @ORM\Table(name="obblm_team_player") |
15
|
|
|
*/ |
16
|
|
|
class Player |
17
|
|
|
{ |
18
|
|
|
/** |
19
|
|
|
* @ORM\Id() |
20
|
|
|
* @ORM\GeneratedValue() |
21
|
|
|
* @ORM\Column(type="integer") |
22
|
|
|
*/ |
23
|
|
|
private $id; |
24
|
|
|
|
25
|
|
|
use NameTrait, DeadAndFireTrait; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @ORM\ManyToOne(targetEntity=Team::class, inversedBy="players") |
29
|
|
|
* @ORM\JoinColumn(nullable=false) |
30
|
|
|
*/ |
31
|
|
|
private $team; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @ORM\Column(type="integer") |
35
|
|
|
*/ |
36
|
|
|
private $number; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @ORM\Column(type="string", length=50) |
40
|
|
|
*/ |
41
|
|
|
private $position; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @ORM\Column(type="string", length=255) |
45
|
|
|
*/ |
46
|
|
|
private $starPlayer = false; |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @ORM\OneToMany(targetEntity=PlayerVersion::class, mappedBy="player", orphanRemoval=true, cascade={"remove"}) |
50
|
|
|
* @ORM\OrderBy({"id"="DESC"}) |
51
|
|
|
*/ |
52
|
|
|
private $versions; |
53
|
|
|
|
54
|
2 |
|
public function __construct() |
55
|
|
|
{ |
56
|
2 |
|
$this->versions = new ArrayCollection(); |
57
|
2 |
|
} |
58
|
|
|
|
59
|
|
|
public function getId(): ?int |
60
|
|
|
{ |
61
|
|
|
return $this->id; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
public function getTeam(): ?Team |
65
|
|
|
{ |
66
|
|
|
return $this->team; |
67
|
|
|
} |
68
|
|
|
|
69
|
2 |
|
public function setTeam(?Team $team): self |
70
|
|
|
{ |
71
|
2 |
|
$this->team = $team; |
72
|
|
|
|
73
|
2 |
|
return $this; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
public function getNumber(): ?int |
77
|
|
|
{ |
78
|
|
|
return $this->number; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
public function setNumber(int $number): self |
82
|
|
|
{ |
83
|
|
|
$this->number = $number; |
84
|
|
|
|
85
|
|
|
return $this; |
86
|
|
|
} |
87
|
|
|
|
88
|
1 |
|
public function getPosition(): ?string |
89
|
|
|
{ |
90
|
1 |
|
return $this->position; |
91
|
|
|
} |
92
|
|
|
|
93
|
2 |
|
public function setPosition(?string $position): self |
94
|
|
|
{ |
95
|
2 |
|
$this->position = $position; |
96
|
|
|
|
97
|
2 |
|
return $this; |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
public function getStarPlayer(): ?bool |
101
|
|
|
{ |
102
|
|
|
return $this->starPlayer; |
|
|
|
|
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
public function isStarPlayer(): ?bool |
106
|
|
|
{ |
107
|
|
|
return $this->starPlayer; |
|
|
|
|
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
public function setStarPlayer(bool $starPlayer): self |
111
|
|
|
{ |
112
|
|
|
$this->starPlayer = $starPlayer; |
|
|
|
|
113
|
|
|
|
114
|
|
|
return $this; |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* @return Collection|PlayerVersion[] |
119
|
|
|
*/ |
120
|
|
|
public function getVersions(): Collection |
121
|
|
|
{ |
122
|
|
|
return $this->versions; |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
public function addVersion(PlayerVersion $version): self |
126
|
|
|
{ |
127
|
|
|
if (!$this->versions->contains($version)) { |
128
|
|
|
$this->versions[] = $version; |
129
|
|
|
$version->setPlayer($this); |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
return $this; |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
public function removeVersion(PlayerVersion $version): self |
136
|
|
|
{ |
137
|
|
|
if ($this->versions->contains($version)) { |
138
|
|
|
$this->versions->removeElement($version); |
139
|
|
|
// set the owning side to null (unless already changed) |
140
|
|
|
if ($version->getPlayer() === $this) { |
141
|
|
|
$version->setPlayer(null); |
142
|
|
|
} |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
return $this; |
146
|
|
|
} |
147
|
|
|
} |
148
|
|
|
|