]> Raphaël G. Git Repositories - airbundle/blob - Entity/Snippet.php
Add font-display: swap CSS directive
[airbundle] / Entity / Snippet.php
1 <?php declare(strict_types=1);
2
3 /*
4 * this file is part of the rapsys packbundle package.
5 *
6 * (c) raphaël gertz <symfony@rapsys.eu>
7 *
8 * for the full copyright and license information, please view the license
9 * file that was distributed with this source code.
10 */
11
12 namespace Rapsys\AirBundle\Entity;
13
14 use Doctrine\ORM\Event\PreUpdateEventArgs;
15
16 /**
17 * Snippet
18 */
19 class Snippet {
20 /**
21 * @var integer
22 */
23 private $id;
24
25 /**
26 * @var string
27 */
28 protected $locale;
29
30 /**
31 * @var string
32 */
33 protected $description;
34
35 /**
36 * @var string
37 */
38 protected $class;
39
40 /**
41 * @var string
42 */
43 protected $short;
44
45 /**
46 * @var integer
47 */
48 protected $rate;
49
50 /**
51 * @var bool
52 */
53 protected $hat;
54
55 /**
56 * @var string
57 */
58 protected $contact;
59
60 /**
61 * @var string
62 */
63 protected $donate;
64
65 /**
66 * @var string
67 */
68 protected $link;
69
70 /**
71 * @var string
72 */
73 protected $profile;
74
75 /**
76 * @var \DateTime
77 */
78 protected $created;
79
80 /**
81 * @var \DateTime
82 */
83 protected $updated;
84
85 /**
86 * @var Location
87 */
88 protected $location;
89
90 /**
91 * @var User
92 */
93 protected $user;
94
95 /**
96 * Constructor
97 */
98 public function __construct() {
99 //Set defaults
100 $this->description = null;
101 $this->class = null;
102 $this->short = null;
103 $this->rate = null;
104 $this->hat = null;
105 $this->contact = null;
106 $this->donate = null;
107 $this->link = null;
108 $this->profile = null;
109 $this->location = null;
110 $this->created = new \DateTime('now');
111 $this->updated = new \DateTime('now');
112 }
113
114 /**
115 * Get id
116 *
117 * @return integer
118 */
119 public function getId(): int {
120 return $this->id;
121 }
122
123 /**
124 * Set locale
125 *
126 * @param string $locale
127 *
128 * @return Snippet
129 */
130 public function setLocale(string $locale): Snippet {
131 $this->locale = $locale;
132
133 return $this;
134 }
135
136 /**
137 * Get locale
138 *
139 * @return string
140 */
141 public function getLocale(): string {
142 return $this->locale;
143 }
144
145 /**
146 * Set description
147 *
148 * @param string $description
149 *
150 * @return Snippet
151 */
152 public function setDescription(?string $description): Snippet {
153 $this->description = $description;
154
155 return $this;
156 }
157
158 /**
159 * Get description
160 *
161 * @return string
162 */
163 public function getDescription(): ?string {
164 return $this->description;
165 }
166
167 /**
168 * Set class
169 *
170 * @param string $class
171 *
172 * @return Snippet
173 */
174 public function setClass(?string $class): Snippet {
175 $this->class = $class;
176
177 return $this;
178 }
179
180 /**
181 * Get class
182 *
183 * @return string
184 */
185 public function getClass(): ?string {
186 return $this->class;
187 }
188
189 /**
190 * Set short
191 *
192 * @param string $short
193 *
194 * @return Snippet
195 */
196 public function setShort(?string $short): Snippet {
197 $this->short = $short;
198
199 return $this;
200 }
201
202 /**
203 * Get short
204 *
205 * @return string
206 */
207 public function getShort(): ?string {
208 return $this->short;
209 }
210
211 /**
212 * Set rate
213 *
214 * @param int $rate
215 *
216 * @return Snippet
217 */
218 public function setRate(?int $rate): Snippet {
219 $this->rate = $rate;
220
221 return $this;
222 }
223
224 /**
225 * Get rate
226 *
227 * @return int
228 */
229 public function getRate(): ?int {
230 return $this->rate;
231 }
232
233 /**
234 * Set hat
235 *
236 * @param bool $hat
237 *
238 * @return User
239 */
240 public function setHat(?bool $hat): Snippet {
241 $this->hat = $hat;
242
243 return $this;
244 }
245
246 /**
247 * Get hat
248 *
249 * @return bool
250 */
251 public function getHat(): ?bool {
252 return $this->hat;
253 }
254 /**
255 * Set contact
256 *
257 * @param string $contact
258 *
259 * @return Snippet
260 */
261 public function setContact(?string $contact): Snippet {
262 $this->contact = $contact;
263
264 return $this;
265 }
266
267 /**
268 * Get contact
269 *
270 * @return string
271 */
272 public function getContact(): ?string {
273 return $this->contact;
274 }
275
276 /**
277 * Set donate
278 *
279 * @param string $donate
280 *
281 * @return Snippet
282 */
283 public function setDonate(?string $donate): Snippet {
284 $this->donate = $donate;
285
286 return $this;
287 }
288
289 /**
290 * Get donate
291 *
292 * @return string
293 */
294 public function getDonate(): ?string {
295 return $this->donate;
296 }
297
298 /**
299 * Set link
300 *
301 * @param string $link
302 *
303 * @return Snippet
304 */
305 public function setLink(?string $link): Snippet {
306 $this->link = $link;
307
308 return $this;
309 }
310
311 /**
312 * Get link
313 *
314 * @return string
315 */
316 public function getLink(): ?string {
317 return $this->link;
318 }
319
320 /**
321 * Set profile
322 *
323 * @param string $profile
324 *
325 * @return Snippet
326 */
327 public function setProfile(?string $profile): Snippet {
328 $this->profile = $profile;
329
330 return $this;
331 }
332
333 /**
334 * Get profile
335 *
336 * @return string
337 */
338 public function getProfile(): ?string {
339 return $this->profile;
340 }
341
342 /**
343 * Set created
344 *
345 * @param \DateTime $created
346 *
347 * @return Snippet
348 */
349 public function setCreated(\DateTime $created): Snippet {
350 $this->created = $created;
351
352 return $this;
353 }
354
355 /**
356 * Get created
357 *
358 * @return \DateTime
359 */
360 public function getCreated(): \DateTime {
361 return $this->created;
362 }
363
364 /**
365 * Set updated
366 *
367 * @param \DateTime $updated
368 *
369 * @return Snippet
370 */
371 public function setUpdated(\DateTime $updated): Snippet {
372 $this->updated = $updated;
373
374 return $this;
375 }
376
377 /**
378 * Get updated
379 *
380 * @return \DateTime
381 */
382 public function getUpdated(): \DateTime {
383 return $this->updated;
384 }
385
386 /**
387 * Set location
388 *
389 * @param Location $location
390 *
391 * @return Snippet
392 */
393 public function setLocation(Location $location) {
394 $this->location = $location;
395
396 return $this;
397 }
398
399 /**
400 * Get location
401 *
402 * @return Location
403 */
404 public function getLocation() {
405 return $this->location;
406 }
407
408 /**
409 * Set user
410 *
411 * @param User $user
412 *
413 * @return Snippet
414 */
415 public function setUser(User $user) {
416 $this->user = $user;
417
418 return $this;
419 }
420
421 /**
422 * Get user
423 *
424 * @return User
425 */
426 public function getUser() {
427 return $this->user;
428 }
429
430 /**
431 * {@inheritdoc}
432 */
433 public function preUpdate(PreUpdateEventArgs $eventArgs) {
434 //Check that we have an snippet instance
435 if (($snippet = $eventArgs->getEntity()) instanceof Snippet) {
436 //Set updated value
437 $snippet->setUpdated(new \DateTime('now'));
438 }
439 }
440 }