1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Stfalcon\Bundle\SponsorBundle\Entity; |
4
|
|
|
|
5
|
|
|
use Doctrine\ORM\Mapping as ORM; |
6
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
7
|
|
|
use Gedmo\Translatable\Translatable; |
8
|
|
|
use Stfalcon\Bundle\EventBundle\Traits\TranslateTrait; |
9
|
|
|
use Symfony\Component\HttpFoundation\File\File; |
10
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
11
|
|
|
use Gedmo\Mapping\Annotation as Gedmo; |
12
|
|
|
use Vich\UploaderBundle\Mapping\Annotation as Vich; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Stfalcon\Bundle\SponsorBundle\Entity\Sponsor. |
16
|
|
|
* |
17
|
|
|
* @Vich\Uploadable |
18
|
|
|
* |
19
|
|
|
* @ORM\Table(name="sponsors") |
20
|
|
|
* @ORM\Entity(repositoryClass="Stfalcon\Bundle\SponsorBundle\Repository\SponsorRepository") |
21
|
|
|
* |
22
|
|
|
* @Gedmo\TranslationEntity(class="Stfalcon\Bundle\SponsorBundle\Entity\Translation\SponsorTranslation") |
23
|
|
|
*/ |
24
|
|
|
class Sponsor implements Translatable |
25
|
|
|
{ |
26
|
|
|
use TranslateTrait; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @var int |
30
|
|
|
* |
31
|
|
|
* @ORM\Column(type="integer") |
32
|
|
|
* @ORM\Id |
33
|
|
|
* @ORM\GeneratedValue(strategy="AUTO") |
34
|
|
|
*/ |
35
|
|
|
protected $id; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @ORM\OneToMany( |
39
|
|
|
* targetEntity="Stfalcon\Bundle\SponsorBundle\Entity\Translation\SponsorTranslation", |
40
|
|
|
* mappedBy="object", |
41
|
|
|
* cascade={"persist", "remove"} |
42
|
|
|
* ) |
43
|
|
|
*/ |
44
|
|
|
private $translations; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @var string |
48
|
|
|
* |
49
|
|
|
* @ORM\Column(name="name", type="string", length=255) |
50
|
|
|
*/ |
51
|
|
|
protected $name; |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @var string |
55
|
|
|
* |
56
|
|
|
* @ORM\Column(name="site", type="string", nullable=true, length=255) |
57
|
|
|
* |
58
|
|
|
* @Assert\Url |
59
|
|
|
*/ |
60
|
|
|
protected $site; |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @var string |
64
|
|
|
* |
65
|
|
|
* @ORM\Column(name="logo", type="string", nullable=true, length=255) |
66
|
|
|
*/ |
67
|
|
|
protected $logo; |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @var int |
71
|
|
|
* |
72
|
|
|
* @ORM\Column(name="sort_order", type="integer", nullable=false) |
73
|
|
|
*/ |
74
|
|
|
protected $sortOrder = 1; |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @var string |
78
|
|
|
* |
79
|
|
|
* @ORM\Column(name="about", type="text", nullable=true) |
80
|
|
|
* |
81
|
|
|
* @Gedmo\Translatable(fallback=true) |
82
|
|
|
*/ |
83
|
|
|
protected $about; |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* @var resource |
87
|
|
|
* |
88
|
|
|
* @Assert\File(maxSize="6000000") |
89
|
|
|
* @Assert\Image |
90
|
|
|
* |
91
|
|
|
* @Vich\UploadableField(mapping="sponsor_image", fileNameProperty="logo") |
92
|
|
|
*/ |
93
|
|
|
protected $file; |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* @ORM\OneToMany(targetEntity="Stfalcon\Bundle\SponsorBundle\Entity\EventSponsor", |
97
|
|
|
* mappedBy="sponsor", cascade={"persist", "remove"}, orphanRemoval=true |
98
|
|
|
* ) |
99
|
|
|
*/ |
100
|
|
|
protected $sponsorEvents; |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* @var \DateTime |
104
|
|
|
* |
105
|
|
|
* @ORM\Column(name="created_at", type="datetime") |
106
|
|
|
* |
107
|
|
|
* @Gedmo\Timestampable(on="create") |
108
|
|
|
*/ |
109
|
|
|
protected $createdAt; |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* @var \DateTime |
113
|
|
|
* |
114
|
|
|
* @ORM\Column(name="updated_at", type="datetime") |
115
|
|
|
* |
116
|
|
|
* @Gedmo\Timestampable(on="update") |
117
|
|
|
*/ |
118
|
|
|
protected $updatedAt; |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* Constructor. |
122
|
|
|
*/ |
123
|
|
|
public function __construct() |
124
|
|
|
{ |
125
|
|
|
$this->sponsorEvents = new ArrayCollection(); |
126
|
|
|
$this->translations = new ArrayCollection(); |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* Get id. |
131
|
|
|
* |
132
|
|
|
* @return int |
133
|
|
|
*/ |
134
|
|
|
public function getId() |
135
|
|
|
{ |
136
|
|
|
return $this->id; |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
/** |
140
|
|
|
* Set name. |
141
|
|
|
* |
142
|
|
|
* @param string $name |
143
|
|
|
* |
144
|
|
|
* @return $this |
145
|
|
|
*/ |
146
|
|
|
public function setName($name) |
147
|
|
|
{ |
148
|
|
|
$this->name = $name; |
149
|
|
|
|
150
|
|
|
return $this; |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
/** |
154
|
|
|
* Get name. |
155
|
|
|
* |
156
|
|
|
* @return string |
157
|
|
|
*/ |
158
|
|
|
public function getName() |
159
|
|
|
{ |
160
|
|
|
return $this->name; |
161
|
|
|
} |
162
|
|
|
|
163
|
|
|
/** |
164
|
|
|
* Get logo filename. |
165
|
|
|
* |
166
|
|
|
* @return string |
167
|
|
|
*/ |
168
|
|
|
public function getLogo() |
169
|
|
|
{ |
170
|
|
|
return $this->logo; |
171
|
|
|
} |
172
|
|
|
|
173
|
|
|
/** |
174
|
|
|
* Set logo filename. |
175
|
|
|
* |
176
|
|
|
* @param string $logo |
177
|
|
|
* |
178
|
|
|
* @return $this |
179
|
|
|
*/ |
180
|
|
|
public function setLogo($logo) |
181
|
|
|
{ |
182
|
|
|
$this->logo = $logo; |
183
|
|
|
|
184
|
|
|
return $this; |
185
|
|
|
} |
186
|
|
|
|
187
|
|
|
/** |
188
|
|
|
* Set sortOrder. |
189
|
|
|
* |
190
|
|
|
* @param int $sortOrder |
191
|
|
|
* |
192
|
|
|
* @return $this |
193
|
|
|
*/ |
194
|
|
|
public function setSortOrder($sortOrder) |
195
|
|
|
{ |
196
|
|
|
$this->sortOrder = $sortOrder; |
197
|
|
|
|
198
|
|
|
return $this; |
199
|
|
|
} |
200
|
|
|
|
201
|
|
|
/** |
202
|
|
|
* Get sortOrder. |
203
|
|
|
* |
204
|
|
|
* @return int |
205
|
|
|
*/ |
206
|
|
|
public function getSortOrder() |
207
|
|
|
{ |
208
|
|
|
return $this->sortOrder; |
209
|
|
|
} |
210
|
|
|
|
211
|
|
|
/** |
212
|
|
|
* Set site. |
213
|
|
|
* |
214
|
|
|
* @param string $site |
215
|
|
|
* |
216
|
|
|
* @return $this |
217
|
|
|
*/ |
218
|
|
|
public function setSite($site) |
219
|
|
|
{ |
220
|
|
|
$this->site = $site; |
221
|
|
|
|
222
|
|
|
return $this; |
223
|
|
|
} |
224
|
|
|
|
225
|
|
|
/** |
226
|
|
|
* Get site. |
227
|
|
|
* |
228
|
|
|
* @return string |
229
|
|
|
*/ |
230
|
|
|
public function getSite() |
231
|
|
|
{ |
232
|
|
|
return $this->site; |
233
|
|
|
} |
234
|
|
|
|
235
|
|
|
/** |
236
|
|
|
* @return resource |
237
|
|
|
*/ |
238
|
|
|
public function getFile() |
239
|
|
|
{ |
240
|
|
|
return $this->file; |
241
|
|
|
} |
242
|
|
|
|
243
|
|
|
/** |
244
|
|
|
* @param File $file |
245
|
|
|
* |
246
|
|
|
* @return $this |
247
|
|
|
*/ |
248
|
|
|
public function setFile($file) |
249
|
|
|
{ |
250
|
|
|
$this->file = $file; |
|
|
|
|
251
|
|
|
|
252
|
|
|
return $this; |
253
|
|
|
} |
254
|
|
|
|
255
|
|
|
/** |
256
|
|
|
* @param EventSponsor $sponsorEvent |
257
|
|
|
* |
258
|
|
|
* @return $this |
259
|
|
|
*/ |
260
|
|
|
public function addSponsorEvent(EventSponsor $sponsorEvent) |
261
|
|
|
{ |
262
|
|
|
$sponsorEvent->setSponsor($this); |
263
|
|
|
$this->sponsorEvents->add($sponsorEvent); |
264
|
|
|
|
265
|
|
|
return $this; |
266
|
|
|
} |
267
|
|
|
|
268
|
|
|
/** |
269
|
|
|
* @param EventSponsor $sponsorEvent |
270
|
|
|
* |
271
|
|
|
* @return $this |
272
|
|
|
*/ |
273
|
|
|
public function removeSponsorEvent(EventSponsor $sponsorEvent) |
274
|
|
|
{ |
275
|
|
|
if ($this->sponsorEvents->contains($sponsorEvent)) { |
276
|
|
|
$this->sponsorEvents->removeElement($sponsorEvent); |
277
|
|
|
$sponsorEvent->setCategory(null) |
278
|
|
|
->setEvent(null) |
279
|
|
|
->setSponsor(null) |
280
|
|
|
; |
281
|
|
|
} |
282
|
|
|
|
283
|
|
|
return $this; |
284
|
|
|
} |
285
|
|
|
|
286
|
|
|
/** |
287
|
|
|
* @param ArrayCollection $sponsorEvents |
288
|
|
|
* |
289
|
|
|
* @return $this |
290
|
|
|
*/ |
291
|
|
|
public function setSponsorEvents($sponsorEvents) |
292
|
|
|
{ |
293
|
|
|
foreach ($sponsorEvents as $sponsorEvent) { |
294
|
|
|
$sponsorEvent->setSponsor($this); |
295
|
|
|
} |
296
|
|
|
$this->sponsorEvents = $sponsorEvents; |
297
|
|
|
|
298
|
|
|
return $this; |
299
|
|
|
} |
300
|
|
|
|
301
|
|
|
/** |
302
|
|
|
* @return ArrayCollection |
303
|
|
|
*/ |
304
|
|
|
public function getSponsorEvents() |
305
|
|
|
{ |
306
|
|
|
return $this->sponsorEvents; |
307
|
|
|
} |
308
|
|
|
|
309
|
|
|
/** |
310
|
|
|
* Get createdAt. |
311
|
|
|
* |
312
|
|
|
* @return \Datetime createdAt |
313
|
|
|
*/ |
314
|
|
|
public function getCreatedAt() |
315
|
|
|
{ |
316
|
|
|
return $this->createdAt; |
317
|
|
|
} |
318
|
|
|
|
319
|
|
|
/** |
320
|
|
|
* Set createdAt. |
321
|
|
|
* |
322
|
|
|
* @param \Datetime $createdAt createdAt |
323
|
|
|
* |
324
|
|
|
* @return $this |
325
|
|
|
*/ |
326
|
|
|
public function setCreatedAt($createdAt) |
327
|
|
|
{ |
328
|
|
|
$this->createdAt = $createdAt; |
329
|
|
|
|
330
|
|
|
return $this; |
331
|
|
|
} |
332
|
|
|
|
333
|
|
|
/** |
334
|
|
|
* Get updatedAt. |
335
|
|
|
* |
336
|
|
|
* @return \Datetime updatedAt |
337
|
|
|
*/ |
338
|
|
|
public function getUpdatedAt() |
339
|
|
|
{ |
340
|
|
|
return $this->updatedAt; |
341
|
|
|
} |
342
|
|
|
|
343
|
|
|
/** |
344
|
|
|
* Set updatedAt. |
345
|
|
|
* |
346
|
|
|
* @param \Datetime $updatedAt updatedAt |
347
|
|
|
* |
348
|
|
|
* @return $this |
349
|
|
|
*/ |
350
|
|
|
public function setUpdatedAt($updatedAt) |
351
|
|
|
{ |
352
|
|
|
$this->updatedAt = $updatedAt; |
353
|
|
|
|
354
|
|
|
return $this; |
355
|
|
|
} |
356
|
|
|
|
357
|
|
|
/** |
358
|
|
|
* Get sponsor name if object treated like a string. |
359
|
|
|
* |
360
|
|
|
* @return string |
361
|
|
|
*/ |
362
|
|
|
public function __toString() |
363
|
|
|
{ |
364
|
|
|
return (string) $this->getName() ?: '-'; |
365
|
|
|
} |
366
|
|
|
|
367
|
|
|
/** |
368
|
|
|
* @return string |
369
|
|
|
*/ |
370
|
|
|
public function getAbout() |
371
|
|
|
{ |
372
|
|
|
return $this->about; |
373
|
|
|
} |
374
|
|
|
|
375
|
|
|
/** |
376
|
|
|
* @param string $about |
377
|
|
|
* |
378
|
|
|
* @return $this |
379
|
|
|
*/ |
380
|
|
|
public function setAbout($about) |
381
|
|
|
{ |
382
|
|
|
$this->about = $about; |
383
|
|
|
|
384
|
|
|
return $this; |
385
|
|
|
} |
386
|
|
|
} |
387
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..