]>
Commit | Line | Data |
---|---|---|
9d50517c NL |
1 | <?php |
2 | ||
ad4d1caa | 3 | namespace Wallabag\CoreBundle\Entity; |
9d50517c | 4 | |
0a018fe0 | 5 | use Doctrine\Common\Collections\ArrayCollection; |
9d50517c | 6 | use Doctrine\ORM\Mapping as ORM; |
0f006880 | 7 | use Hateoas\Configuration\Annotation as Hateoas; |
7d1fdab2 | 8 | use JMS\Serializer\Annotation\Exclude; |
f808b016 | 9 | use JMS\Serializer\Annotation\Groups; |
7d1fdab2 | 10 | use JMS\Serializer\Annotation\SerializedName; |
f808b016 JB |
11 | use JMS\Serializer\Annotation\VirtualProperty; |
12 | use JMS\Serializer\Annotation\XmlRoot; | |
619cc453 | 13 | use Symfony\Component\Validator\Constraints as Assert; |
4dc87223 | 14 | use Wallabag\AnnotationBundle\Entity\Annotation; |
927c9e79 | 15 | use Wallabag\CoreBundle\Helper\EntityTimestampsTrait; |
f808b016 | 16 | use Wallabag\UserBundle\Entity\User; |
9d50517c NL |
17 | |
18 | /** | |
4346a860 | 19 | * Entry. |
9d50517c | 20 | * |
0f006880 | 21 | * @XmlRoot("entry") |
be463487 | 22 | * @ORM\Entity(repositoryClass="Wallabag\CoreBundle\Repository\EntryRepository") |
7e9c1d65 JB |
23 | * @ORM\Table( |
24 | * name="`entry`", | |
25 | * options={"collate"="utf8mb4_unicode_ci", "charset"="utf8mb4"}, | |
81375151 NL |
26 | * indexes={ |
27 | * @ORM\Index(name="created_at", columns={"created_at"}), | |
7239082a | 28 | * @ORM\Index(name="uid", columns={"uid"}) |
81375151 | 29 | * } |
7e9c1d65 | 30 | * ) |
34d15eb4 | 31 | * @ORM\HasLifecycleCallbacks() |
0f006880 | 32 | * @Hateoas\Relation("self", href = "expr('/api/entries/' ~ object.getId())") |
9d50517c | 33 | */ |
be463487 | 34 | class Entry |
9d50517c | 35 | { |
927c9e79 JB |
36 | use EntityTimestampsTrait; |
37 | ||
0f006880 | 38 | /** @Serializer\XmlAttribute */ |
9d50517c | 39 | /** |
4346a860 | 40 | * @var int |
9d50517c | 41 | * |
be463487 | 42 | * @ORM\Column(name="id", type="integer") |
9d50517c | 43 | * @ORM\Id |
34d15eb4 | 44 | * @ORM\GeneratedValue(strategy="AUTO") |
5b7da076 TC |
45 | * |
46 | * @Groups({"entries_for_user", "export_all"}) | |
9d50517c | 47 | */ |
be463487 | 48 | private $id; |
9d50517c | 49 | |
f3d0cb91 | 50 | /** |
78b3c31d | 51 | * @var string |
f3d0cb91 | 52 | * |
7239082a | 53 | * @ORM\Column(name="uid", type="string", length=23, nullable=true) |
f3d0cb91 NL |
54 | * |
55 | * @Groups({"entries_for_user", "export_all"}) | |
56 | */ | |
7239082a | 57 | private $uid; |
f3d0cb91 | 58 | |
9d50517c NL |
59 | /** |
60 | * @var string | |
61 | * | |
62 | * @ORM\Column(name="title", type="text", nullable=true) | |
5b7da076 TC |
63 | * |
64 | * @Groups({"entries_for_user", "export_all"}) | |
9d50517c NL |
65 | */ |
66 | private $title; | |
67 | ||
68 | /** | |
69 | * @var string | |
70 | * | |
b84a8055 | 71 | * @Assert\NotBlank() |
9d50517c | 72 | * @ORM\Column(name="url", type="text", nullable=true) |
5b7da076 TC |
73 | * |
74 | * @Groups({"entries_for_user", "export_all"}) | |
9d50517c NL |
75 | */ |
76 | private $url; | |
77 | ||
78 | /** | |
4346a860 | 79 | * @var bool |
9d50517c | 80 | * |
189ef634 TC |
81 | * @Exclude |
82 | * | |
be463487 | 83 | * @ORM\Column(name="is_archived", type="boolean") |
5b7da076 TC |
84 | * |
85 | * @Groups({"entries_for_user", "export_all"}) | |
9d50517c | 86 | */ |
905ae369 | 87 | private $isArchived = false; |
9d50517c NL |
88 | |
89 | /** | |
4346a860 | 90 | * @var bool |
9d50517c | 91 | * |
189ef634 TC |
92 | * @Exclude |
93 | * | |
be463487 | 94 | * @ORM\Column(name="is_starred", type="boolean") |
5b7da076 TC |
95 | * |
96 | * @Groups({"entries_for_user", "export_all"}) | |
9d50517c | 97 | */ |
905ae369 | 98 | private $isStarred = false; |
9d50517c | 99 | |
9d50517c NL |
100 | /** |
101 | * @var string | |
102 | * | |
eacaf7f8 | 103 | * @ORM\Column(name="content", type="text", nullable=true) |
5b7da076 TC |
104 | * |
105 | * @Groups({"entries_for_user", "export_all"}) | |
9d50517c | 106 | */ |
eacaf7f8 | 107 | private $content; |
9d50517c | 108 | |
34d15eb4 | 109 | /** |
8664069e | 110 | * @var \DateTime |
34d15eb4 | 111 | * |
be463487 | 112 | * @ORM\Column(name="created_at", type="datetime") |
5b7da076 | 113 | * |
9401696f | 114 | * @Groups({"entries_for_user", "export_all"}) |
34d15eb4 NL |
115 | */ |
116 | private $createdAt; | |
117 | ||
118 | /** | |
8664069e | 119 | * @var \DateTime |
34d15eb4 | 120 | * |
be463487 | 121 | * @ORM\Column(name="updated_at", type="datetime") |
5b7da076 | 122 | * |
9401696f | 123 | * @Groups({"entries_for_user", "export_all"}) |
34d15eb4 NL |
124 | */ |
125 | private $updatedAt; | |
126 | ||
5e9009ce NL |
127 | /** |
128 | * @var \DateTime | |
129 | * | |
130 | * @ORM\Column(name="published_at", type="datetime", nullable=true) | |
131 | * | |
132 | * @Groups({"entries_for_user", "export_all"}) | |
133 | */ | |
134 | private $publishedAt; | |
135 | ||
7b0b3622 NL |
136 | /** |
137 | * @var array | |
138 | * | |
1517d577 | 139 | * @ORM\Column(name="published_by", type="array", nullable=true) |
7b0b3622 NL |
140 | * |
141 | * @Groups({"entries_for_user", "export_all"}) | |
142 | */ | |
143 | private $publishedBy; | |
144 | ||
a991c46e F |
145 | /** |
146 | * @var \DateTime | |
147 | * | |
148 | * @ORM\Column(name="starred_at", type="datetime", nullable=true) | |
149 | * | |
150 | * @Groups({"entries_for_user", "export_all"}) | |
151 | */ | |
152 | private $starredAt = null; | |
153 | ||
34d15eb4 | 154 | /** |
4dc87223 | 155 | * @ORM\OneToMany(targetEntity="Wallabag\AnnotationBundle\Entity\Annotation", mappedBy="entry", cascade={"persist", "remove"}) |
f38e03dc | 156 | * @ORM\JoinTable |
5b7da076 | 157 | * |
f38e03dc | 158 | * @Groups({"entries_for_user", "export_all"}) |
34d15eb4 | 159 | */ |
4dc87223 | 160 | private $annotations; |
34d15eb4 NL |
161 | |
162 | /** | |
163 | * @var string | |
164 | * | |
165 | * @ORM\Column(name="mimetype", type="text", nullable=true) | |
5b7da076 TC |
166 | * |
167 | * @Groups({"entries_for_user", "export_all"}) | |
34d15eb4 NL |
168 | */ |
169 | private $mimetype; | |
170 | ||
98f0929f JB |
171 | /** |
172 | * @var string | |
173 | * | |
174 | * @ORM\Column(name="language", type="text", nullable=true) | |
5b7da076 TC |
175 | * |
176 | * @Groups({"entries_for_user", "export_all"}) | |
98f0929f JB |
177 | */ |
178 | private $language; | |
179 | ||
34d15eb4 | 180 | /** |
4346a860 | 181 | * @var int |
34d15eb4 | 182 | * |
26864574 | 183 | * @ORM\Column(name="reading_time", type="integer", nullable=true) |
5b7da076 TC |
184 | * |
185 | * @Groups({"entries_for_user", "export_all"}) | |
34d15eb4 NL |
186 | */ |
187 | private $readingTime; | |
188 | ||
189 | /** | |
190 | * @var string | |
191 | * | |
192 | * @ORM\Column(name="domain_name", type="text", nullable=true) | |
5b7da076 TC |
193 | * |
194 | * @Groups({"entries_for_user", "export_all"}) | |
34d15eb4 NL |
195 | */ |
196 | private $domainName; | |
197 | ||
fad31615 JB |
198 | /** |
199 | * @var string | |
200 | * | |
201 | * @ORM\Column(name="preview_picture", type="text", nullable=true) | |
5b7da076 TC |
202 | * |
203 | * @Groups({"entries_for_user", "export_all"}) | |
fad31615 JB |
204 | */ |
205 | private $previewPicture; | |
206 | ||
10b35097 | 207 | /** |
e10e6ab3 | 208 | * @var string |
10b35097 | 209 | * |
3ef75cc4 | 210 | * @ORM\Column(name="http_status", type="string", length=3, nullable=true) |
10b35097 NL |
211 | * |
212 | * @Groups({"entries_for_user", "export_all"}) | |
213 | */ | |
214 | private $httpStatus; | |
215 | ||
dda6a6ad NL |
216 | /** |
217 | * @var array | |
218 | * | |
1517d577 | 219 | * @ORM\Column(name="headers", type="array", nullable=true) |
dda6a6ad NL |
220 | * |
221 | * @Groups({"entries_for_user", "export_all"}) | |
222 | */ | |
223 | private $headers; | |
224 | ||
5f09650e | 225 | /** |
7d1fdab2 TC |
226 | * @Exclude |
227 | * | |
1210dae1 | 228 | * @ORM\ManyToOne(targetEntity="Wallabag\UserBundle\Entity\User", inversedBy="entries") |
5b7da076 TC |
229 | * |
230 | * @Groups({"export_all"}) | |
5f09650e NL |
231 | */ |
232 | private $user; | |
233 | ||
0a018fe0 | 234 | /** |
af95c09c | 235 | * @ORM\ManyToMany(targetEntity="Tag", inversedBy="entries", cascade={"persist"}) |
e42b13bc JB |
236 | * @ORM\JoinTable( |
237 | * name="entry_tag", | |
238 | * joinColumns={ | |
206bade5 | 239 | * @ORM\JoinColumn(name="entry_id", referencedColumnName="id", onDelete="cascade") |
e42b13bc JB |
240 | * }, |
241 | * inverseJoinColumns={ | |
206bade5 | 242 | * @ORM\JoinColumn(name="tag_id", referencedColumnName="id", onDelete="cascade") |
e42b13bc JB |
243 | * } |
244 | * ) | |
0a018fe0 NL |
245 | */ |
246 | private $tags; | |
247 | ||
5f09650e NL |
248 | /* |
249 | * @param User $user | |
250 | */ | |
5d6f6f56 | 251 | public function __construct(User $user) |
5f09650e NL |
252 | { |
253 | $this->user = $user; | |
0a018fe0 | 254 | $this->tags = new ArrayCollection(); |
5f09650e NL |
255 | } |
256 | ||
9d50517c | 257 | /** |
4346a860 | 258 | * Get id. |
9d50517c | 259 | * |
4346a860 | 260 | * @return int |
9d50517c NL |
261 | */ |
262 | public function getId() | |
263 | { | |
264 | return $this->id; | |
265 | } | |
266 | ||
267 | /** | |
4346a860 JB |
268 | * Set title. |
269 | * | |
270 | * @param string $title | |
9d50517c | 271 | * |
be463487 | 272 | * @return Entry |
9d50517c NL |
273 | */ |
274 | public function setTitle($title) | |
275 | { | |
276 | $this->title = $title; | |
277 | ||
278 | return $this; | |
279 | } | |
280 | ||
281 | /** | |
4346a860 | 282 | * Get title. |
9d50517c | 283 | * |
7df80cb3 | 284 | * @return string |
9d50517c NL |
285 | */ |
286 | public function getTitle() | |
287 | { | |
288 | return $this->title; | |
289 | } | |
290 | ||
291 | /** | |
4346a860 JB |
292 | * Set url. |
293 | * | |
294 | * @param string $url | |
9d50517c | 295 | * |
be463487 | 296 | * @return Entry |
9d50517c NL |
297 | */ |
298 | public function setUrl($url) | |
299 | { | |
300 | $this->url = $url; | |
301 | ||
302 | return $this; | |
303 | } | |
304 | ||
305 | /** | |
4346a860 | 306 | * Get url. |
9d50517c | 307 | * |
7df80cb3 | 308 | * @return string |
9d50517c NL |
309 | */ |
310 | public function getUrl() | |
311 | { | |
312 | return $this->url; | |
313 | } | |
314 | ||
315 | /** | |
4346a860 JB |
316 | * Set isArchived. |
317 | * | |
8eedc8cf | 318 | * @param bool $isArchived |
9d50517c | 319 | * |
be463487 | 320 | * @return Entry |
9d50517c | 321 | */ |
905ae369 | 322 | public function setArchived($isArchived) |
9d50517c | 323 | { |
905ae369 | 324 | $this->isArchived = $isArchived; |
9d50517c NL |
325 | |
326 | return $this; | |
327 | } | |
328 | ||
329 | /** | |
4346a860 | 330 | * Get isArchived. |
9d50517c | 331 | * |
8eedc8cf | 332 | * @return bool |
9d50517c | 333 | */ |
905ae369 | 334 | public function isArchived() |
9d50517c | 335 | { |
905ae369 | 336 | return $this->isArchived; |
9d50517c NL |
337 | } |
338 | ||
189ef634 TC |
339 | /** |
340 | * @VirtualProperty | |
341 | * @SerializedName("is_archived") | |
342 | * @Groups({"entries_for_user", "export_all"}) | |
343 | */ | |
344 | public function is_Archived() | |
345 | { | |
346 | return (int) $this->isArchived(); | |
347 | } | |
348 | ||
163eae0b NL |
349 | public function toggleArchive() |
350 | { | |
905ae369 | 351 | $this->isArchived = $this->isArchived() ^ 1; |
7df80cb3 | 352 | |
163eae0b NL |
353 | return $this; |
354 | } | |
355 | ||
9d50517c | 356 | /** |
4346a860 JB |
357 | * Set isStarred. |
358 | * | |
8eedc8cf | 359 | * @param bool $isStarred |
9d50517c | 360 | * |
be463487 | 361 | * @return Entry |
9d50517c | 362 | */ |
905ae369 | 363 | public function setStarred($isStarred) |
9d50517c | 364 | { |
905ae369 | 365 | $this->isStarred = $isStarred; |
9d50517c NL |
366 | |
367 | return $this; | |
368 | } | |
369 | ||
370 | /** | |
4346a860 | 371 | * Get isStarred. |
9d50517c | 372 | * |
8eedc8cf | 373 | * @return bool |
9d50517c | 374 | */ |
905ae369 | 375 | public function isStarred() |
9d50517c | 376 | { |
905ae369 | 377 | return $this->isStarred; |
9d50517c NL |
378 | } |
379 | ||
189ef634 TC |
380 | /** |
381 | * @VirtualProperty | |
382 | * @SerializedName("is_starred") | |
383 | * @Groups({"entries_for_user", "export_all"}) | |
384 | */ | |
385 | public function is_Starred() | |
386 | { | |
387 | return (int) $this->isStarred(); | |
388 | } | |
389 | ||
163eae0b NL |
390 | public function toggleStar() |
391 | { | |
905ae369 | 392 | $this->isStarred = $this->isStarred() ^ 1; |
163eae0b NL |
393 | |
394 | return $this; | |
395 | } | |
396 | ||
9d50517c | 397 | /** |
4346a860 JB |
398 | * Set content. |
399 | * | |
400 | * @param string $content | |
9d50517c | 401 | * |
be463487 | 402 | * @return Entry |
9d50517c NL |
403 | */ |
404 | public function setContent($content) | |
405 | { | |
406 | $this->content = $content; | |
407 | ||
408 | return $this; | |
409 | } | |
410 | ||
411 | /** | |
4346a860 | 412 | * Get content. |
9d50517c | 413 | * |
7df80cb3 | 414 | * @return string |
9d50517c NL |
415 | */ |
416 | public function getContent() | |
417 | { | |
418 | return $this->content; | |
419 | } | |
420 | ||
421 | /** | |
5f09650e | 422 | * @return User |
9d50517c | 423 | */ |
5f09650e | 424 | public function getUser() |
9d50517c | 425 | { |
5f09650e | 426 | return $this->user; |
9d50517c | 427 | } |
42a90646 | 428 | |
7d1fdab2 TC |
429 | /** |
430 | * @VirtualProperty | |
431 | * @SerializedName("user_name") | |
432 | */ | |
433 | public function getUserName() | |
434 | { | |
435 | return $this->user->getUserName(); | |
436 | } | |
437 | ||
438 | /** | |
439 | * @VirtualProperty | |
440 | * @SerializedName("user_email") | |
441 | */ | |
442 | public function getUserEmail() | |
443 | { | |
444 | return $this->user->getEmail(); | |
445 | } | |
446 | ||
447 | /** | |
448 | * @VirtualProperty | |
449 | * @SerializedName("user_id") | |
450 | */ | |
451 | public function getUserId() | |
452 | { | |
453 | return $this->user->getId(); | |
454 | } | |
455 | ||
34d15eb4 | 456 | /** |
6d65c0a8 JB |
457 | * Set created_at. |
458 | * Only used when importing data from an other service. | |
459 | * | |
8664069e | 460 | * @param \DateTime $createdAt |
6d65c0a8 JB |
461 | * |
462 | * @return Entry | |
463 | */ | |
464 | public function setCreatedAt(\DateTime $createdAt) | |
465 | { | |
466 | $this->createdAt = $createdAt; | |
467 | ||
468 | return $this; | |
469 | } | |
470 | ||
471 | /** | |
8664069e | 472 | * @return \DateTime |
34d15eb4 NL |
473 | */ |
474 | public function getCreatedAt() | |
475 | { | |
476 | return $this->createdAt; | |
477 | } | |
478 | ||
34d15eb4 | 479 | /** |
8664069e | 480 | * @return \DateTime |
34d15eb4 NL |
481 | */ |
482 | public function getUpdatedAt() | |
483 | { | |
484 | return $this->updatedAt; | |
485 | } | |
486 | ||
a991c46e F |
487 | /** |
488 | * @return \DateTime|null | |
489 | */ | |
490 | public function getStarredAt() | |
491 | { | |
492 | return $this->starredAt; | |
493 | } | |
494 | ||
495 | /** | |
496 | * @param \DateTime|null $starredAt | |
497 | * | |
498 | * @return Entry | |
499 | */ | |
500 | public function setStarredAt($starredAt = null) | |
501 | { | |
502 | $this->starredAt = $starredAt; | |
503 | ||
504 | return $this; | |
505 | } | |
506 | ||
507 | /** | |
508 | * update isStarred and starred_at fields. | |
509 | * | |
510 | * @param bool $isStarred | |
511 | * | |
512 | * @return Entry | |
513 | */ | |
514 | public function updateStar($isStarred = false) | |
515 | { | |
516 | $this->setStarred($isStarred); | |
517 | $this->setStarredAt(null); | |
518 | if ($this->isStarred()) { | |
519 | $this->setStarredAt(new \DateTime()); | |
520 | } | |
521 | ||
522 | return $this; | |
523 | } | |
524 | ||
34d15eb4 | 525 | /** |
4dc87223 | 526 | * @return ArrayCollection<Annotation> |
34d15eb4 | 527 | */ |
4dc87223 | 528 | public function getAnnotations() |
34d15eb4 | 529 | { |
4dc87223 | 530 | return $this->annotations; |
34d15eb4 NL |
531 | } |
532 | ||
533 | /** | |
4dc87223 | 534 | * @param Annotation $annotation |
34d15eb4 | 535 | */ |
4dc87223 | 536 | public function setAnnotation(Annotation $annotation) |
34d15eb4 | 537 | { |
4dc87223 | 538 | $this->annotations[] = $annotation; |
34d15eb4 NL |
539 | } |
540 | ||
541 | /** | |
542 | * @return string | |
543 | */ | |
544 | public function getMimetype() | |
545 | { | |
546 | return $this->mimetype; | |
547 | } | |
548 | ||
549 | /** | |
550 | * @param string $mimetype | |
551 | */ | |
552 | public function setMimetype($mimetype) | |
553 | { | |
554 | $this->mimetype = $mimetype; | |
555 | } | |
556 | ||
557 | /** | |
558 | * @return int | |
559 | */ | |
560 | public function getReadingTime() | |
561 | { | |
562 | return $this->readingTime; | |
563 | } | |
564 | ||
565 | /** | |
566 | * @param int $readingTime | |
567 | */ | |
568 | public function setReadingTime($readingTime) | |
569 | { | |
570 | $this->readingTime = $readingTime; | |
571 | } | |
572 | ||
573 | /** | |
574 | * @return string | |
575 | */ | |
576 | public function getDomainName() | |
577 | { | |
578 | return $this->domainName; | |
579 | } | |
580 | ||
581 | /** | |
582 | * @param string $domainName | |
583 | */ | |
584 | public function setDomainName($domainName) | |
585 | { | |
586 | $this->domainName = $domainName; | |
587 | } | |
588 | ||
0a018fe0 | 589 | /** |
4ec53ab7 | 590 | * @return ArrayCollection |
0a018fe0 NL |
591 | */ |
592 | public function getTags() | |
593 | { | |
594 | return $this->tags; | |
595 | } | |
596 | ||
b0458874 JB |
597 | /** |
598 | * @VirtualProperty | |
599 | * @SerializedName("tags") | |
600 | * @Groups({"entries_for_user", "export_all"}) | |
601 | */ | |
602 | public function getSerializedTags() | |
603 | { | |
604 | $data = []; | |
605 | foreach ($this->tags as $tag) { | |
606 | $data[] = $tag->getLabel(); | |
607 | } | |
608 | ||
609 | return $data; | |
610 | } | |
611 | ||
0a018fe0 NL |
612 | /** |
613 | * @param Tag $tag | |
614 | */ | |
615 | public function addTag(Tag $tag) | |
616 | { | |
625acf33 KG |
617 | if ($this->tags->contains($tag)) { |
618 | return; | |
619 | } | |
620 | ||
fc031e57 JB |
621 | // check if tag already exist but has not yet be persisted |
622 | // it seems that the previous condition with `contains()` doesn't check that case | |
623 | foreach ($this->tags as $existingTag) { | |
fc732227 | 624 | if ($existingTag->getLabel() === $tag->getLabel()) { |
fc031e57 JB |
625 | return; |
626 | } | |
627 | } | |
628 | ||
e42b13bc | 629 | $this->tags->add($tag); |
46bbd8d3 | 630 | $tag->addEntry($this); |
0a018fe0 | 631 | } |
092ca707 | 632 | |
a05b6115 JB |
633 | /** |
634 | * Remove the given tag from the entry (if the tag is associated). | |
635 | * | |
636 | * @param Tag $tag | |
637 | */ | |
092ca707 NL |
638 | public function removeTag(Tag $tag) |
639 | { | |
e42b13bc JB |
640 | if (!$this->tags->contains($tag)) { |
641 | return; | |
642 | } | |
643 | ||
092ca707 | 644 | $this->tags->removeElement($tag); |
e42b13bc | 645 | $tag->removeEntry($this); |
092ca707 | 646 | } |
fad31615 | 647 | |
a05b6115 JB |
648 | /** |
649 | * Remove all assigned tags from the entry. | |
650 | */ | |
651 | public function removeAllTags() | |
652 | { | |
653 | foreach ($this->tags as $tag) { | |
654 | $this->tags->removeElement($tag); | |
655 | $tag->removeEntry($this); | |
656 | } | |
657 | } | |
658 | ||
fad31615 | 659 | /** |
a1413a3d | 660 | * Set previewPicture. |
fad31615 JB |
661 | * |
662 | * @param string $previewPicture | |
663 | * | |
664 | * @return Entry | |
665 | */ | |
666 | public function setPreviewPicture($previewPicture) | |
667 | { | |
668 | $this->previewPicture = $previewPicture; | |
669 | ||
670 | return $this; | |
671 | } | |
672 | ||
673 | /** | |
a1413a3d | 674 | * Get previewPicture. |
fad31615 JB |
675 | * |
676 | * @return string | |
677 | */ | |
678 | public function getPreviewPicture() | |
679 | { | |
680 | return $this->previewPicture; | |
681 | } | |
98f0929f JB |
682 | |
683 | /** | |
684 | * Set language. | |
685 | * | |
686 | * @param string $language | |
687 | * | |
688 | * @return Entry | |
689 | */ | |
690 | public function setLanguage($language) | |
691 | { | |
692 | $this->language = $language; | |
693 | ||
694 | return $this; | |
695 | } | |
696 | ||
697 | /** | |
698 | * Get language. | |
699 | * | |
700 | * @return string | |
701 | */ | |
702 | public function getLanguage() | |
703 | { | |
704 | return $this->language; | |
705 | } | |
f3d0cb91 NL |
706 | |
707 | /** | |
78b3c31d | 708 | * @return string |
f3d0cb91 | 709 | */ |
7239082a | 710 | public function getUid() |
f3d0cb91 | 711 | { |
7239082a | 712 | return $this->uid; |
f3d0cb91 NL |
713 | } |
714 | ||
715 | /** | |
7239082a | 716 | * @param string $uid |
f3d0cb91 NL |
717 | * |
718 | * @return Entry | |
719 | */ | |
7239082a | 720 | public function setUid($uid) |
f3d0cb91 | 721 | { |
7239082a | 722 | $this->uid = $uid; |
f3d0cb91 NL |
723 | |
724 | return $this; | |
725 | } | |
726 | ||
7239082a | 727 | public function generateUid() |
f3d0cb91 | 728 | { |
7239082a | 729 | if (null === $this->uid) { |
a7e2218e | 730 | // @see http://blog.kevingomez.fr/til/2015/07/26/why-is-uniqid-slow/ for true parameter |
7239082a | 731 | $this->uid = uniqid('', true); |
f3d0cb91 NL |
732 | } |
733 | } | |
f1be7af4 | 734 | |
7239082a | 735 | public function cleanUid() |
f1be7af4 | 736 | { |
7239082a | 737 | $this->uid = null; |
f1be7af4 | 738 | } |
10b35097 | 739 | |
e8911f7c JB |
740 | /** |
741 | * Used in the entries filter so it's more explicit for the end user than the uid. | |
a9c6577f | 742 | * Also used in the API. |
e8911f7c | 743 | * |
1112e547 JB |
744 | * @VirtualProperty |
745 | * @SerializedName("is_public") | |
746 | * @Groups({"entries_for_user"}) | |
747 | * | |
e8911f7c JB |
748 | * @return bool |
749 | */ | |
750 | public function isPublic() | |
751 | { | |
752 | return null !== $this->uid; | |
753 | } | |
754 | ||
10b35097 | 755 | /** |
5fe65bae | 756 | * @return string |
10b35097 NL |
757 | */ |
758 | public function getHttpStatus() | |
759 | { | |
760 | return $this->httpStatus; | |
761 | } | |
762 | ||
763 | /** | |
5fe65bae | 764 | * @param string $httpStatus |
10b35097 NL |
765 | * |
766 | * @return Entry | |
767 | */ | |
768 | public function setHttpStatus($httpStatus) | |
769 | { | |
770 | $this->httpStatus = $httpStatus; | |
771 | ||
772 | return $this; | |
773 | } | |
5e9009ce NL |
774 | |
775 | /** | |
776 | * @return \Datetime | |
777 | */ | |
778 | public function getPublishedAt() | |
779 | { | |
780 | return $this->publishedAt; | |
781 | } | |
782 | ||
783 | /** | |
784 | * @param \Datetime $publishedAt | |
785 | * | |
786 | * @return Entry | |
787 | */ | |
788 | public function setPublishedAt(\Datetime $publishedAt) | |
789 | { | |
790 | $this->publishedAt = $publishedAt; | |
791 | ||
792 | return $this; | |
793 | } | |
7b0b3622 NL |
794 | |
795 | /** | |
dda6a6ad | 796 | * @return array |
7b0b3622 NL |
797 | */ |
798 | public function getPublishedBy() | |
799 | { | |
800 | return $this->publishedBy; | |
801 | } | |
802 | ||
803 | /** | |
1517d577 | 804 | * @param array $publishedBy |
7b0b3622 NL |
805 | * |
806 | * @return Entry | |
807 | */ | |
808 | public function setPublishedBy($publishedBy) | |
809 | { | |
810 | $this->publishedBy = $publishedBy; | |
811 | ||
812 | return $this; | |
813 | } | |
dda6a6ad NL |
814 | |
815 | /** | |
816 | * @return array | |
817 | */ | |
818 | public function getHeaders() | |
819 | { | |
820 | return $this->headers; | |
821 | } | |
822 | ||
823 | /** | |
1517d577 | 824 | * @param array $headers |
dda6a6ad NL |
825 | * |
826 | * @return Entry | |
827 | */ | |
828 | public function setHeaders($headers) | |
829 | { | |
830 | $this->headers = $headers; | |
831 | ||
832 | return $this; | |
833 | } | |
9d50517c | 834 | } |