1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace FSi\FixturesBundle\Entity; |
4
|
|
|
|
5
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
6
|
|
|
use Doctrine\Common\Collections\Collection; |
7
|
|
|
use Doctrine\ORM\Mapping as ORM; |
8
|
|
|
use FSi\Bundle\DoctrineExtensionsBundle\Validator\Constraints as UploadableAssert; |
9
|
|
|
use FSi\DoctrineExtensions\Uploadable\Mapping\Annotation as Uploadable; |
10
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* @ORM\Entity |
14
|
|
|
* @ORM\Table(name="news") |
15
|
|
|
*/ |
16
|
|
|
class News |
17
|
|
|
{ |
18
|
|
|
/** |
19
|
|
|
* @ORM\Column(type="integer") |
20
|
|
|
* @ORM\Id |
21
|
|
|
* @ORM\GeneratedValue(strategy="AUTO") |
22
|
|
|
*/ |
23
|
|
|
protected $id; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @ORM\Column(type="string", length=100) |
27
|
|
|
*/ |
28
|
|
|
protected $title; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @ORM\Column(type="string", length=100, nullable=true) |
32
|
|
|
*/ |
33
|
|
|
protected $subtitle; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @ORM\Column(type="date", nullable=true) |
37
|
|
|
*/ |
38
|
|
|
protected $date; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @ORM\Column(type="boolean") |
42
|
|
|
*/ |
43
|
|
|
protected $visible; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @ORM\Column(type="datetime", name="created_at") |
47
|
|
|
*/ |
48
|
|
|
protected $createdAt; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @ORM\Column(type="text", name="creator_email") |
52
|
|
|
*/ |
53
|
|
|
protected $creatorEmail; |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @ORM\Column(length=255, nullable=true) |
57
|
|
|
* @Uploadable\Uploadable(targetField="photo") |
58
|
|
|
*/ |
59
|
|
|
protected $photoKey; |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @var \FSi\DoctrineExtensions\Uploadable\File|\SplFileInfo |
63
|
|
|
* @UploadableAssert\Image() |
64
|
|
|
*/ |
65
|
|
|
protected $photo; |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @var Category[]|Collection |
69
|
|
|
* |
70
|
|
|
* @ORM\ManyToMany(targetEntity="Category") |
71
|
|
|
*/ |
72
|
|
|
protected $categories; |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* @var Tag[]|Collection |
76
|
|
|
* |
77
|
|
|
* @Assert\Valid |
78
|
|
|
* @ORM\OneToMany(targetEntity="Tag", mappedBy="news", cascade={"persist"}, orphanRemoval=true) |
79
|
|
|
*/ |
80
|
|
|
protected $tags; |
81
|
|
|
|
82
|
|
|
public function __construct() |
83
|
|
|
{ |
84
|
|
|
$this->categories = new ArrayCollection(); |
85
|
|
|
$this->tags = new ArrayCollection(); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* @return mixed |
90
|
|
|
*/ |
91
|
|
|
public function getId() |
92
|
|
|
{ |
93
|
|
|
return $this->id; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* @param mixed $id |
98
|
|
|
* @return News |
99
|
|
|
*/ |
100
|
|
|
public function setId($id) |
101
|
|
|
{ |
102
|
|
|
$this->id = $id; |
103
|
|
|
return $this; |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* @param mixed $createdAt |
108
|
|
|
*/ |
109
|
|
|
public function setCreatedAt($createdAt) |
110
|
|
|
{ |
111
|
|
|
$this->createdAt = $createdAt; |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* @return mixed |
116
|
|
|
*/ |
117
|
|
|
public function getCreatedAt() |
118
|
|
|
{ |
119
|
|
|
return $this->createdAt; |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
/** |
123
|
|
|
* @param mixed $creatorEmail |
124
|
|
|
*/ |
125
|
|
|
public function setCreatorEmail($creatorEmail) |
126
|
|
|
{ |
127
|
|
|
$this->creatorEmail = $creatorEmail; |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
/** |
131
|
|
|
* @return mixed |
132
|
|
|
*/ |
133
|
|
|
public function getCreatorEmail() |
134
|
|
|
{ |
135
|
|
|
return $this->creatorEmail; |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
/** |
139
|
|
|
* @param mixed $title |
140
|
|
|
*/ |
141
|
|
|
public function setTitle($title) |
142
|
|
|
{ |
143
|
|
|
$this->title = $title; |
144
|
|
|
} |
145
|
|
|
|
146
|
|
|
/** |
147
|
|
|
* @return mixed |
148
|
|
|
*/ |
149
|
|
|
public function getTitle() |
150
|
|
|
{ |
151
|
|
|
return $this->title; |
152
|
|
|
} |
153
|
|
|
|
154
|
|
|
/** |
155
|
|
|
* @param mixed $subtitle |
156
|
|
|
*/ |
157
|
|
|
public function setSubtitle($subtitle) |
158
|
|
|
{ |
159
|
|
|
$this->subtitle = $subtitle; |
160
|
|
|
} |
161
|
|
|
|
162
|
|
|
/** |
163
|
|
|
* @return mixed |
164
|
|
|
*/ |
165
|
|
|
public function getSubtitle() |
166
|
|
|
{ |
167
|
|
|
return $this->subtitle; |
168
|
|
|
} |
169
|
|
|
|
170
|
|
|
/** |
171
|
|
|
* @param mixed $date |
172
|
|
|
*/ |
173
|
|
|
public function setDate($date) |
174
|
|
|
{ |
175
|
|
|
$this->date = $date; |
176
|
|
|
} |
177
|
|
|
|
178
|
|
|
/** |
179
|
|
|
* @return mixed |
180
|
|
|
*/ |
181
|
|
|
public function getDate() |
182
|
|
|
{ |
183
|
|
|
return $this->date; |
184
|
|
|
} |
185
|
|
|
|
186
|
|
|
/** |
187
|
|
|
* @param mixed $visible |
188
|
|
|
* @return News |
189
|
|
|
*/ |
190
|
|
|
public function setVisible($visible) |
191
|
|
|
{ |
192
|
|
|
$this->visible = (boolean) $visible; |
193
|
|
|
return $this; |
194
|
|
|
} |
195
|
|
|
|
196
|
|
|
/** |
197
|
|
|
* @return mixed |
198
|
|
|
*/ |
199
|
|
|
public function isVisible() |
200
|
|
|
{ |
201
|
|
|
return $this->visible; |
202
|
|
|
} |
203
|
|
|
|
204
|
|
|
/** |
205
|
|
|
* @return mixed |
206
|
|
|
*/ |
207
|
|
|
public function getPhotoKey() |
208
|
|
|
{ |
209
|
|
|
return $this->photoKey; |
210
|
|
|
} |
211
|
|
|
|
212
|
|
|
/** |
213
|
|
|
* @param mixed $photoKey |
214
|
|
|
*/ |
215
|
|
|
public function setPhotoKey($photoKey) |
216
|
|
|
{ |
217
|
|
|
$this->photoKey = $photoKey; |
218
|
|
|
} |
219
|
|
|
|
220
|
|
|
/** |
221
|
|
|
* @return \FSi\DoctrineExtensions\Uploadable\File|\SplFileInfo |
222
|
|
|
*/ |
223
|
|
|
public function getPhoto() |
224
|
|
|
{ |
225
|
|
|
return $this->photo; |
226
|
|
|
} |
227
|
|
|
|
228
|
|
|
/** |
229
|
|
|
* @param \FSi\DoctrineExtensions\Uploadable\File|\SplFileInfo $photo |
230
|
|
|
*/ |
231
|
|
|
public function setPhoto($photo) |
232
|
|
|
{ |
233
|
|
|
$this->photo = $photo; |
234
|
|
|
} |
235
|
|
|
|
236
|
|
|
public function addCategory(Category $category) |
237
|
|
|
{ |
238
|
|
|
$this->categories->add($category); |
239
|
|
|
} |
240
|
|
|
|
241
|
|
|
public function removeCategory(Category $category) |
242
|
|
|
{ |
243
|
|
|
$this->categories->removeElement($category); |
244
|
|
|
} |
245
|
|
|
|
246
|
|
|
/** |
247
|
|
|
* @return mixed |
248
|
|
|
*/ |
249
|
|
|
public function getCategories() |
250
|
|
|
{ |
251
|
|
|
return (array) $this->categories; |
252
|
|
|
} |
253
|
|
|
|
254
|
|
|
/** |
255
|
|
|
* @return Tag[]|ArrayCollection |
256
|
|
|
*/ |
257
|
|
|
public function getTags() |
258
|
|
|
{ |
259
|
|
|
return $this->tags; |
260
|
|
|
} |
261
|
|
|
|
262
|
|
|
/** |
263
|
|
|
* @param Tag $tag |
264
|
|
|
*/ |
265
|
|
|
public function addTag(Tag $tag) |
266
|
|
|
{ |
267
|
|
|
if (!$this->tags->contains($tag)) { |
268
|
|
|
$tag->setNews($this); |
269
|
|
|
$this->tags->add($tag); |
270
|
|
|
} |
271
|
|
|
} |
272
|
|
|
|
273
|
|
|
/** |
274
|
|
|
* @param Tag $tag |
275
|
|
|
*/ |
276
|
|
|
public function removeTag(Tag $tag) |
277
|
|
|
{ |
278
|
|
|
$tag->setNews(null); |
279
|
|
|
$this->tags->removeElement($tag); |
280
|
|
|
} |
281
|
|
|
|
282
|
|
|
public function setTags(array $tags) |
283
|
|
|
{ |
284
|
|
|
$this->tags = new ArrayCollection($tags); |
285
|
|
|
} |
286
|
|
|
} |
287
|
|
|
|