1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace VideoGamesRecords\CoreBundle\Entity; |
4
|
|
|
|
5
|
|
|
use Doctrine\ORM\Mapping as ORM; |
6
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
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
|
|
|
* Group |
14
|
|
|
* |
15
|
|
|
* @ORM\Table(name="vgr_group", indexes={@ORM\Index(name="idxIdGame", columns={"idGame"}), @ORM\Index(name="idxBoolDlc", columns={"boolDlc"})}) |
16
|
|
|
* @ORM\Entity(repositoryClass="VideoGamesRecords\CoreBundle\Repository\GroupRepository") |
17
|
|
|
* @method GroupTranslation translate(string $locale, bool $fallbackToDefault) |
18
|
|
|
*/ |
19
|
|
|
class Group |
20
|
|
|
{ |
21
|
|
|
use Timestampable; |
22
|
|
|
use Translatable; |
23
|
|
|
use Sluggable; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @var integer |
27
|
|
|
* @ORM\Column(name="id", type="integer") |
28
|
|
|
* @ORM\Id |
29
|
|
|
* @ORM\GeneratedValue(strategy="IDENTITY") |
30
|
|
|
*/ |
31
|
|
|
private $id; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @var boolean |
35
|
|
|
* @ORM\Column(name="boolDlc", type="boolean", nullable=false) |
36
|
|
|
*/ |
37
|
|
|
private $boolDlc = false; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @var integer |
41
|
|
|
* @ORM\Column(name="nbChart", type="integer", nullable=false) |
42
|
|
|
*/ |
43
|
|
|
private $nbChart = 0; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @var integer |
47
|
|
|
* @ORM\Column(name="nbPost", type="integer", nullable=false) |
48
|
|
|
*/ |
49
|
|
|
private $nbPost = 0; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @var integer |
53
|
|
|
* @ORM\Column(name="nbPlayer", type="integer", nullable=false) |
54
|
|
|
*/ |
55
|
|
|
private $nbPlayer = 0; |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @var Game |
59
|
|
|
* |
60
|
|
|
* @Assert\NotNull |
61
|
|
|
* @ORM\ManyToOne(targetEntity="VideoGamesRecords\CoreBundle\Entity\Game", inversedBy="groups") |
62
|
|
|
* @ORM\JoinColumns({ |
63
|
|
|
* @ORM\JoinColumn(name="idGame", referencedColumnName="id", nullable=false) |
64
|
|
|
* }) |
65
|
|
|
*/ |
66
|
|
|
private $game; |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @var Chart[]|ArrayCollection |
70
|
|
|
* |
71
|
|
|
* @ORM\OneToMany(targetEntity="VideoGamesRecords\CoreBundle\Entity\Chart", mappedBy="group") |
72
|
|
|
*/ |
73
|
|
|
private $charts; |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* Constructor |
77
|
|
|
*/ |
78
|
|
|
public function __construct() |
79
|
|
|
{ |
80
|
|
|
$this->charts = new ArrayCollection(); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @return string |
85
|
|
|
*/ |
86
|
|
|
public function __toString() |
87
|
|
|
{ |
88
|
|
|
return sprintf('%s [%s]', $this->getName(), $this->id); |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* Set idGroup |
93
|
|
|
* @param integer $id |
94
|
|
|
* @return Group |
95
|
|
|
*/ |
96
|
|
|
public function setId($id) |
97
|
|
|
{ |
98
|
|
|
$this->id = $id; |
99
|
|
|
return $this; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* Get idGroup |
104
|
|
|
* @return integer |
105
|
|
|
*/ |
106
|
|
|
public function getId() |
107
|
|
|
{ |
108
|
|
|
return $this->id; |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* Get libGroup |
113
|
|
|
* @return string |
114
|
|
|
*/ |
115
|
|
|
public function getLibGroup() |
116
|
|
|
{ |
117
|
|
|
return $this->getName(); |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* @param string $name |
122
|
|
|
* @return $this |
123
|
|
|
*/ |
124
|
|
|
public function setName($name) |
125
|
|
|
{ |
126
|
|
|
$this->translate(null, false)->setName($name); |
127
|
|
|
|
128
|
|
|
return $this; |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
/** |
132
|
|
|
* @return string |
133
|
|
|
*/ |
134
|
|
|
public function getName() |
135
|
|
|
{ |
136
|
|
|
return $this->translate(null, false)->getName(); |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
/** |
140
|
|
|
* Set boolDlc |
141
|
|
|
* @param boolean $boolDlc |
142
|
|
|
* @return Group |
143
|
|
|
*/ |
144
|
|
|
public function setBoolDlc($boolDlc) |
145
|
|
|
{ |
146
|
|
|
$this->boolDlc = $boolDlc; |
147
|
|
|
|
148
|
|
|
return $this; |
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
/** |
152
|
|
|
* Get boolDlc |
153
|
|
|
* @return boolean |
154
|
|
|
*/ |
155
|
|
|
public function getBoolDlc() |
156
|
|
|
{ |
157
|
|
|
return $this->boolDlc; |
158
|
|
|
} |
159
|
|
|
|
160
|
|
|
/** |
161
|
|
|
* Set nbChart |
162
|
|
|
* @param integer $nbChart |
163
|
|
|
* @return Group |
164
|
|
|
*/ |
165
|
|
|
public function setNbChart($nbChart) |
166
|
|
|
{ |
167
|
|
|
$this->nbChart = $nbChart; |
168
|
|
|
|
169
|
|
|
return $this; |
170
|
|
|
} |
171
|
|
|
|
172
|
|
|
/** |
173
|
|
|
* Get nbChart |
174
|
|
|
* @return integer |
175
|
|
|
*/ |
176
|
|
|
public function getNbChart() |
177
|
|
|
{ |
178
|
|
|
return $this->nbChart; |
179
|
|
|
} |
180
|
|
|
|
181
|
|
|
/** |
182
|
|
|
* Set nbPost |
183
|
|
|
* @param integer $nbPost |
184
|
|
|
* @return Group |
185
|
|
|
*/ |
186
|
|
|
public function setNbPost($nbPost) |
187
|
|
|
{ |
188
|
|
|
$this->nbPost = $nbPost; |
189
|
|
|
|
190
|
|
|
return $this; |
191
|
|
|
} |
192
|
|
|
|
193
|
|
|
/** |
194
|
|
|
* Get nbPost |
195
|
|
|
* @return integer |
196
|
|
|
*/ |
197
|
|
|
public function getNbPost() |
198
|
|
|
{ |
199
|
|
|
return $this->nbPost; |
200
|
|
|
} |
201
|
|
|
|
202
|
|
|
/** |
203
|
|
|
* Set nbPlayer |
204
|
|
|
* @param integer $nbPlayer |
205
|
|
|
* @return Group |
206
|
|
|
*/ |
207
|
|
|
public function setNbUser($nbPlayer) |
208
|
|
|
{ |
209
|
|
|
$this->nbPlayer = $nbPlayer; |
210
|
|
|
|
211
|
|
|
return $this; |
212
|
|
|
} |
213
|
|
|
|
214
|
|
|
/** |
215
|
|
|
* Get nbPlayer |
216
|
|
|
* @return integer |
217
|
|
|
*/ |
218
|
|
|
public function getNbUser() |
219
|
|
|
{ |
220
|
|
|
return $this->nbPlayer; |
221
|
|
|
} |
222
|
|
|
|
223
|
|
|
/** |
224
|
|
|
* Set game |
225
|
|
|
* @param Game $game |
226
|
|
|
* @return Group |
227
|
|
|
*/ |
228
|
|
|
public function setGame(Game $game = null) |
229
|
|
|
{ |
230
|
|
|
$this->game = $game; |
231
|
|
|
|
232
|
|
|
return $this; |
233
|
|
|
} |
234
|
|
|
|
235
|
|
|
/** |
236
|
|
|
* Get game |
237
|
|
|
* @return Game |
238
|
|
|
*/ |
239
|
|
|
public function getGame() |
240
|
|
|
{ |
241
|
|
|
return $this->game; |
242
|
|
|
} |
243
|
|
|
|
244
|
|
|
/** |
245
|
|
|
* @param Chart $chart |
246
|
|
|
* @return $this |
247
|
|
|
*/ |
248
|
|
|
public function addChart(Chart $chart) |
249
|
|
|
{ |
250
|
|
|
$this->charts[] = $chart; |
251
|
|
|
return $this; |
252
|
|
|
} |
253
|
|
|
|
254
|
|
|
/** |
255
|
|
|
* @param Chart $chart |
256
|
|
|
*/ |
257
|
|
|
public function removeChart(Chart $chart) |
258
|
|
|
{ |
259
|
|
|
$this->charts->removeElement($chart); |
260
|
|
|
} |
261
|
|
|
|
262
|
|
|
/** |
263
|
|
|
* @return Chart[]|ArrayCollection |
264
|
|
|
*/ |
265
|
|
|
public function getCharts() |
266
|
|
|
{ |
267
|
|
|
return $this->charts; |
268
|
|
|
} |
269
|
|
|
|
270
|
|
|
/** |
271
|
|
|
* Returns an array of the fields used to generate the slug. |
272
|
|
|
* |
273
|
|
|
* @return array |
274
|
|
|
*/ |
275
|
|
|
public function getSluggableFields() |
276
|
|
|
{ |
277
|
|
|
return ['name']; |
278
|
|
|
} |
279
|
|
|
} |
280
|
|
|
|