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