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