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