|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace VideoGamesRecords\CoreBundle\Entity; |
|
4
|
|
|
|
|
5
|
|
|
use ApiPlatform\Core\Annotation\ApiResource; |
|
6
|
|
|
use Doctrine\ORM\Mapping as ORM; |
|
7
|
|
|
use Knp\DoctrineBehaviors\Contract\Entity\TranslatableInterface; |
|
8
|
|
|
use Knp\DoctrineBehaviors\Model\Translatable\TranslatableMethodsTrait; |
|
9
|
|
|
use Knp\DoctrineBehaviors\Model\Translatable\TranslatablePropertiesTrait; |
|
10
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Country |
|
14
|
|
|
* |
|
15
|
|
|
* @ORM\Table(name="vgr_country") |
|
16
|
|
|
* @ORM\Entity |
|
17
|
|
|
* @ApiResource(attributes={"order"={"translations.name"}}) |
|
18
|
|
|
*/ |
|
19
|
|
|
class Country implements TranslatableInterface |
|
20
|
|
|
{ |
|
21
|
|
|
use TranslatablePropertiesTrait; |
|
22
|
|
|
use TranslatableMethodsTrait; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @Assert\Length(min="2", max="2") |
|
26
|
|
|
* @ORM\Column(name="code_iso2", type="string", length=2, nullable=false) |
|
27
|
|
|
*/ |
|
28
|
|
|
private string $codeIso2; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* @Assert\Length(min="3", max="3") |
|
32
|
|
|
* @ORM\Column(name="code_iso3", type="string", length=3, nullable=false) |
|
33
|
|
|
*/ |
|
34
|
|
|
private string $codeIso3; |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* @ORM\Column(name="code_iso_numeric", type="integer", nullable=false) |
|
38
|
|
|
*/ |
|
39
|
|
|
private int $codeIsoNumeric; |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @ORM\Column(name="slug", type="string", length=100, nullable=true) |
|
43
|
|
|
*/ |
|
44
|
|
|
private string $slug; |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* @ORM\Column(name="id", type="integer") |
|
48
|
|
|
* @ORM\Id |
|
49
|
|
|
* @ORM\GeneratedValue(strategy="IDENTITY") |
|
50
|
|
|
*/ |
|
51
|
|
|
private ?int $id = null; |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* @ORM\OneToOne(targetEntity="VideoGamesRecords\CoreBundle\Entity\Badge", inversedBy="country") |
|
55
|
|
|
* @ORM\JoinColumns({ |
|
56
|
|
|
* @ORM\JoinColumn(name="idBadge", referencedColumnName="id") |
|
57
|
|
|
* }) |
|
58
|
|
|
*/ |
|
59
|
|
|
private ?Badge $badge; |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* @ORM\Column(name="boolMaj", type="boolean", nullable=false, options={"default":0}) |
|
63
|
|
|
*/ |
|
64
|
|
|
private bool $boolMaj = false; |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* Set codeIso |
|
68
|
|
|
* |
|
69
|
|
|
* @param string $codeIso2 |
|
70
|
|
|
* @return Country |
|
71
|
|
|
*/ |
|
72
|
|
|
public function setCodeIso2(string $codeIso2): Country |
|
73
|
|
|
{ |
|
74
|
|
|
$this->codeIso2 = $codeIso2; |
|
75
|
|
|
|
|
76
|
|
|
return $this; |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* Get codeIso |
|
81
|
|
|
* |
|
82
|
|
|
* @return string |
|
83
|
|
|
*/ |
|
84
|
|
|
public function getCodeIso2(): string |
|
85
|
|
|
{ |
|
86
|
|
|
return $this->codeIso2; |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
/** |
|
90
|
|
|
* @return string |
|
91
|
|
|
*/ |
|
92
|
|
|
public function getCodeIso3(): string |
|
93
|
|
|
{ |
|
94
|
|
|
return $this->codeIso3; |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
/** |
|
98
|
|
|
* @param string $codeIso3 |
|
99
|
|
|
* @return Country |
|
100
|
|
|
*/ |
|
101
|
|
|
public function setCodeIso3(string $codeIso3): Country |
|
102
|
|
|
{ |
|
103
|
|
|
$this->codeIso3 = $codeIso3; |
|
104
|
|
|
return $this; |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
/** |
|
108
|
|
|
* @return int |
|
109
|
|
|
*/ |
|
110
|
|
|
public function getCodeIsoNumeric(): int |
|
111
|
|
|
{ |
|
112
|
|
|
return $this->codeIsoNumeric; |
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
|
|
/** |
|
116
|
|
|
* @param int $codeIsoNumeric |
|
117
|
|
|
* @return Country |
|
118
|
|
|
*/ |
|
119
|
|
|
public function setCodeIsoNumeric(int $codeIsoNumeric): Country |
|
120
|
|
|
{ |
|
121
|
|
|
$this->codeIsoNumeric = $codeIsoNumeric; |
|
122
|
|
|
return $this; |
|
123
|
|
|
} |
|
124
|
|
|
|
|
125
|
|
|
/** |
|
126
|
|
|
* @param string $name |
|
127
|
|
|
* @return $this |
|
128
|
|
|
*/ |
|
129
|
|
|
public function setName(string $name): Country |
|
130
|
|
|
{ |
|
131
|
|
|
$this->translate(null, false)->setName($name); |
|
|
|
|
|
|
132
|
|
|
|
|
133
|
|
|
return $this; |
|
134
|
|
|
} |
|
135
|
|
|
|
|
136
|
|
|
/** |
|
137
|
|
|
* @return string |
|
138
|
|
|
*/ |
|
139
|
|
|
public function getName(): string |
|
140
|
|
|
{ |
|
141
|
|
|
return $this->translate(null, false)->getName(); |
|
|
|
|
|
|
142
|
|
|
} |
|
143
|
|
|
|
|
144
|
|
|
/** |
|
145
|
|
|
* Get id |
|
146
|
|
|
* |
|
147
|
|
|
* @return int|null |
|
148
|
|
|
*/ |
|
149
|
|
|
public function getId(): ?int |
|
150
|
|
|
{ |
|
151
|
|
|
return $this->id; |
|
152
|
|
|
} |
|
153
|
|
|
|
|
154
|
|
|
/** |
|
155
|
|
|
* Set id |
|
156
|
|
|
* |
|
157
|
|
|
* @param int $id |
|
158
|
|
|
* @return $this |
|
159
|
|
|
*/ |
|
160
|
|
|
public function setId(int $id): Country |
|
161
|
|
|
{ |
|
162
|
|
|
$this->id = $id; |
|
163
|
|
|
|
|
164
|
|
|
return $this; |
|
165
|
|
|
} |
|
166
|
|
|
|
|
167
|
|
|
/** |
|
168
|
|
|
* set badge |
|
169
|
|
|
* @param Badge|null $badge |
|
170
|
|
|
* @return $this |
|
171
|
|
|
*/ |
|
172
|
|
|
public function setBadge(Badge $badge = null): Country |
|
173
|
|
|
{ |
|
174
|
|
|
$this->badge = $badge; |
|
175
|
|
|
|
|
176
|
|
|
return $this; |
|
177
|
|
|
} |
|
178
|
|
|
|
|
179
|
|
|
/** |
|
180
|
|
|
* Get idBadge |
|
181
|
|
|
* @return Badge|null |
|
182
|
|
|
*/ |
|
183
|
|
|
public function getBadge(): ?Badge |
|
184
|
|
|
{ |
|
185
|
|
|
return $this->badge; |
|
186
|
|
|
} |
|
187
|
|
|
|
|
188
|
|
|
/** |
|
189
|
|
|
* Set boolMaj |
|
190
|
|
|
* |
|
191
|
|
|
* @param boolean $boolMaj |
|
192
|
|
|
* @return $this |
|
193
|
|
|
*/ |
|
194
|
|
|
public function setBoolMaj(bool $boolMaj): Country |
|
195
|
|
|
{ |
|
196
|
|
|
$this->boolMaj = $boolMaj; |
|
197
|
|
|
|
|
198
|
|
|
return $this; |
|
199
|
|
|
} |
|
200
|
|
|
|
|
201
|
|
|
/** |
|
202
|
|
|
* Get boolMaj |
|
203
|
|
|
* |
|
204
|
|
|
* @return bool |
|
205
|
|
|
*/ |
|
206
|
|
|
public function getBoolMaj(): bool |
|
207
|
|
|
{ |
|
208
|
|
|
return $this->boolMaj; |
|
209
|
|
|
} |
|
210
|
|
|
|
|
211
|
|
|
public function getSlug(): string |
|
212
|
|
|
{ |
|
213
|
|
|
return $this->slug; |
|
214
|
|
|
} |
|
215
|
|
|
|
|
216
|
|
|
public function setSlug(string $slug): void |
|
217
|
|
|
{ |
|
218
|
|
|
$this->slug = $slug; |
|
219
|
|
|
} |
|
220
|
|
|
|
|
221
|
|
|
/** |
|
222
|
|
|
* @return string |
|
223
|
|
|
*/ |
|
224
|
|
|
public function __toString() |
|
225
|
|
|
{ |
|
226
|
|
|
return sprintf('%s [%d]', $this->getDefaultName(), $this->getId()); |
|
227
|
|
|
} |
|
228
|
|
|
|
|
229
|
|
|
/** |
|
230
|
|
|
* @return string |
|
231
|
|
|
*/ |
|
232
|
|
|
public function getDefaultName(): string |
|
233
|
|
|
{ |
|
234
|
|
|
return $this->translate('en', false)->getName(); |
|
235
|
|
|
} |
|
236
|
|
|
} |
|
237
|
|
|
|