1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace VideoGamesRecords\CoreBundle\Entity; |
4
|
|
|
|
5
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
6
|
|
|
use Doctrine\ORM\Mapping as ORM; |
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
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Chart |
14
|
|
|
* |
15
|
|
|
* @ORM\Table(name="vgr_chart", indexes={@ORM\Index(name="idxIdGroup", columns={"idGroup"}), @ORM\Index(name="idxStatusPlayer", columns={"statusPlayer"}), @ORM\Index(name="idxStatusTeam", columns={"statusTeam"}), @ORM\Index(name="idxStatusTeam", columns={"statusTeam"})}) |
16
|
|
|
* @ORM\Entity(repositoryClass="VideoGamesRecords\CoreBundle\Repository\ChartRepository") |
17
|
|
|
* @method ChartTranslation translate(string $locale, bool $fallbackToDefault) |
18
|
|
|
*/ |
19
|
|
|
class Chart |
20
|
|
|
{ |
21
|
|
|
use Timestampable; |
22
|
|
|
use Translatable; |
23
|
|
|
use Sluggable; |
24
|
|
|
|
25
|
|
|
const STATUS_NORMAL = 'NORMAL'; |
26
|
|
|
const STATUS_MAJ = 'MAJ'; |
27
|
|
|
const STATUS_GO_TO_MAJ = 'goToMAJ'; |
28
|
|
|
const STATUS_ERROR = 'ERREUR'; |
29
|
|
|
const STATUS_WORK_DELETE = 'WORK_DELETE'; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @var integer |
33
|
|
|
* |
34
|
|
|
* @ORM\Column(name="id", type="integer") |
35
|
|
|
* @ORM\Id |
36
|
|
|
* @ORM\GeneratedValue(strategy="IDENTITY") |
37
|
|
|
*/ |
38
|
|
|
private $id; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @var string |
42
|
|
|
* |
43
|
|
|
* @ORM\Column(name="statusPlayer", type="string", nullable=false) |
44
|
|
|
*/ |
45
|
|
|
private $statusPlayer = 'NORMAL'; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @var string |
49
|
|
|
* |
50
|
|
|
* @ORM\Column(name="statusTeam", type="string", nullable=false) |
51
|
|
|
*/ |
52
|
|
|
private $statusTeam = 'NORMAL'; |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @var integer |
56
|
|
|
* |
57
|
|
|
* @ORM\Column(name="nbPost", type="integer", nullable=false) |
58
|
|
|
*/ |
59
|
|
|
private $nbPost = 0; |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @var Group |
63
|
|
|
* |
64
|
|
|
* @Assert\NotNull |
65
|
|
|
* @ORM\ManyToOne(targetEntity="VideoGamesRecords\CoreBundle\Entity\Group", inversedBy="charts") |
66
|
|
|
* @ORM\JoinColumns({ |
67
|
|
|
* @ORM\JoinColumn(name="idGroup", referencedColumnName="id", nullable=false) |
68
|
|
|
* }) |
69
|
|
|
*/ |
70
|
|
|
private $group; |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @var ArrayCollection|\VideoGamesRecords\CoreBundle\Entity\ChartLib[] |
74
|
|
|
* |
75
|
|
|
* @ORM\OneToMany(targetEntity="VideoGamesRecords\CoreBundle\Entity\ChartLib", mappedBy="chart", cascade={"persist", "remove"}, orphanRemoval=true) |
76
|
|
|
*/ |
77
|
|
|
private $libs; |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* @var ArrayCollection|\VideoGamesRecords\CoreBundle\Entity\PlayerChart[] |
81
|
|
|
* |
82
|
|
|
* @ORM\OneToMany(targetEntity="VideoGamesRecords\CoreBundle\Entity\PlayerChart", mappedBy="chart") |
83
|
|
|
*/ |
84
|
|
|
private $playerCharts; |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* Constructor |
88
|
|
|
*/ |
89
|
|
|
public function __construct() |
90
|
|
|
{ |
91
|
|
|
$this->libs = new ArrayCollection(); |
92
|
|
|
$this->playerCharts = new ArrayCollection(); |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* @return string |
97
|
|
|
*/ |
98
|
|
|
public function __toString() |
99
|
|
|
{ |
100
|
|
|
return sprintf('%s [%s]', $this->getName(), $this->id); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* Set idChart |
105
|
|
|
* |
106
|
|
|
* @param integer $id |
107
|
|
|
* @return Chart |
108
|
|
|
*/ |
109
|
|
|
public function setId($id) |
110
|
|
|
{ |
111
|
|
|
$this->id = $id; |
112
|
|
|
|
113
|
|
|
return $this; |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* Get idChart |
118
|
|
|
* |
119
|
|
|
* @return integer |
120
|
|
|
*/ |
121
|
|
|
public function getId() |
122
|
|
|
{ |
123
|
|
|
return $this->id; |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
/** |
127
|
|
|
* Get libChart |
128
|
|
|
* |
129
|
|
|
* @return string |
130
|
|
|
*/ |
131
|
|
|
public function getLibChart() |
132
|
|
|
{ |
133
|
|
|
return $this->getName(); |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
/** |
137
|
|
|
* @param string $name |
138
|
|
|
* @return $this |
139
|
|
|
*/ |
140
|
|
|
public function setName($name) |
141
|
|
|
{ |
142
|
|
|
$this->translate(null, false)->setName($name); |
143
|
|
|
|
144
|
|
|
return $this; |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
/** |
148
|
|
|
* @return string |
149
|
|
|
*/ |
150
|
|
|
public function getName() |
151
|
|
|
{ |
152
|
|
|
return $this->translate(null, false)->getName(); |
153
|
|
|
} |
154
|
|
|
|
155
|
|
|
/** |
156
|
|
|
* Set statusPlayer |
157
|
|
|
* |
158
|
|
|
* @param string $statusPlayer |
159
|
|
|
* @return Chart |
160
|
|
|
*/ |
161
|
|
|
public function setStatusPlayer($statusPlayer) |
162
|
|
|
{ |
163
|
|
|
$this->statusPlayer = $statusPlayer; |
164
|
|
|
return $this; |
165
|
|
|
} |
166
|
|
|
|
167
|
|
|
/** |
168
|
|
|
* Get statusPlayer |
169
|
|
|
* |
170
|
|
|
* @return string |
171
|
|
|
*/ |
172
|
|
|
public function getStatusPlayer() |
173
|
|
|
{ |
174
|
|
|
return $this->statusPlayer; |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
/** |
178
|
|
|
* Set statusTeam |
179
|
|
|
* |
180
|
|
|
* @param string $statusTeam |
181
|
|
|
* @return Chart |
182
|
|
|
*/ |
183
|
|
|
public function setStatusTeam($statusTeam) |
184
|
|
|
{ |
185
|
|
|
$this->statusTeam = $statusTeam; |
186
|
|
|
return $this; |
187
|
|
|
} |
188
|
|
|
|
189
|
|
|
/** |
190
|
|
|
* Get statusTeam |
191
|
|
|
* |
192
|
|
|
* @return string |
193
|
|
|
*/ |
194
|
|
|
public function getStatusTeam() |
195
|
|
|
{ |
196
|
|
|
return $this->statusTeam; |
197
|
|
|
} |
198
|
|
|
|
199
|
|
|
/** |
200
|
|
|
* @return \Doctrine\Common\Collections\ArrayCollection|\VideoGamesRecords\CoreBundle\Entity\PlayerChart[] |
201
|
|
|
*/ |
202
|
|
|
public function getPlayerCharts() |
203
|
|
|
{ |
204
|
|
|
return $this->playerCharts; |
205
|
|
|
} |
206
|
|
|
|
207
|
|
|
/** |
208
|
|
|
* @param \Doctrine\Common\Collections\ArrayCollection|\VideoGamesRecords\CoreBundle\Entity\PlayerChart[] $playerCharts |
209
|
|
|
* |
210
|
|
|
* @return Chart |
211
|
|
|
*/ |
212
|
|
|
public function setPlayerCharts($playerCharts) |
213
|
|
|
{ |
214
|
|
|
$this->playerCharts = $playerCharts; |
215
|
|
|
|
216
|
|
|
return $this; |
217
|
|
|
} |
218
|
|
|
|
219
|
|
|
/** |
220
|
|
|
* Set nbPost |
221
|
|
|
* |
222
|
|
|
* @param integer $nbPost |
223
|
|
|
* @return Chart |
224
|
|
|
*/ |
225
|
|
|
public function setNbPost($nbPost) |
226
|
|
|
{ |
227
|
|
|
$this->nbPost = $nbPost; |
228
|
|
|
return $this; |
229
|
|
|
} |
230
|
|
|
|
231
|
|
|
/** |
232
|
|
|
* Get nbPost |
233
|
|
|
* |
234
|
|
|
* @return integer |
235
|
|
|
*/ |
236
|
|
|
public function getNbPost() |
237
|
|
|
{ |
238
|
|
|
return $this->nbPost; |
239
|
|
|
} |
240
|
|
|
|
241
|
|
|
/** |
242
|
|
|
* Set group |
243
|
|
|
* |
244
|
|
|
* @param Group $group |
245
|
|
|
* @return Chart |
246
|
|
|
*/ |
247
|
|
|
public function setGroup(Group $group = null) |
248
|
|
|
{ |
249
|
|
|
$this->group = $group; |
250
|
|
|
|
251
|
|
|
return $this; |
252
|
|
|
} |
253
|
|
|
|
254
|
|
|
/** |
255
|
|
|
* Get group |
256
|
|
|
* |
257
|
|
|
* @return Group |
258
|
|
|
*/ |
259
|
|
|
public function getGroup() |
260
|
|
|
{ |
261
|
|
|
return $this->group; |
262
|
|
|
} |
263
|
|
|
|
264
|
|
|
/** |
265
|
|
|
* @param ChartLib $lib |
266
|
|
|
* @return $this |
267
|
|
|
*/ |
268
|
|
|
public function addLib(ChartLib $lib) |
269
|
|
|
{ |
270
|
|
|
$lib->setChart($this); |
271
|
|
|
$this->libs[] = $lib; |
272
|
|
|
return $this; |
273
|
|
|
} |
274
|
|
|
|
275
|
|
|
/** |
276
|
|
|
* @param ChartLib $lib |
277
|
|
|
*/ |
278
|
|
|
public function removeLib(ChartLib $lib) |
279
|
|
|
{ |
280
|
|
|
$this->libs->removeElement($lib); |
281
|
|
|
} |
282
|
|
|
|
283
|
|
|
/** |
284
|
|
|
* @return ArrayCollection|\VideoGamesRecords\CoreBundle\Entity\ChartLib[] |
285
|
|
|
*/ |
286
|
|
|
public function getLibs() |
287
|
|
|
{ |
288
|
|
|
return $this->libs; |
289
|
|
|
} |
290
|
|
|
|
291
|
|
|
|
292
|
|
|
/** |
293
|
|
|
* @return array |
294
|
|
|
*/ |
295
|
|
|
public static function getStatusChoices() |
296
|
|
|
{ |
297
|
|
|
return [ |
298
|
|
|
self::STATUS_NORMAL => self::STATUS_NORMAL, |
299
|
|
|
self::STATUS_MAJ => self::STATUS_MAJ, |
300
|
|
|
self::STATUS_GO_TO_MAJ => self::STATUS_GO_TO_MAJ, |
301
|
|
|
self::STATUS_ERROR => self::STATUS_ERROR, |
302
|
|
|
self::STATUS_WORK_DELETE => self::STATUS_WORK_DELETE, |
303
|
|
|
]; |
304
|
|
|
} |
305
|
|
|
|
306
|
|
|
/** |
307
|
|
|
* Returns an array of the fields used to generate the slug. |
308
|
|
|
* |
309
|
|
|
* @return array |
310
|
|
|
*/ |
311
|
|
|
public function getSluggableFields() |
312
|
|
|
{ |
313
|
|
|
return ['name']; |
314
|
|
|
} |
315
|
|
|
} |
316
|
|
|
|