]>
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; |
268e9e72 | 8 | use JMS\Serializer\Annotation\Groups; |
0f006880 | 9 | use JMS\Serializer\Annotation\XmlRoot; |
7d1fdab2 TC |
10 | use JMS\Serializer\Annotation\Exclude; |
11 | use JMS\Serializer\Annotation\VirtualProperty; | |
12 | use JMS\Serializer\Annotation\SerializedName; | |
619cc453 | 13 | use Symfony\Component\Validator\Constraints as Assert; |
1210dae1 | 14 | use Wallabag\UserBundle\Entity\User; |
4dc87223 | 15 | use Wallabag\AnnotationBundle\Entity\Annotation; |
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 | ||
34d15eb4 | 133 | /** |
4dc87223 | 134 | * @ORM\OneToMany(targetEntity="Wallabag\AnnotationBundle\Entity\Annotation", mappedBy="entry", cascade={"persist", "remove"}) |
f38e03dc | 135 | * @ORM\JoinTable |
5b7da076 | 136 | * |
f38e03dc | 137 | * @Groups({"entries_for_user", "export_all"}) |
34d15eb4 | 138 | */ |
4dc87223 | 139 | private $annotations; |
34d15eb4 NL |
140 | |
141 | /** | |
142 | * @var string | |
143 | * | |
144 | * @ORM\Column(name="mimetype", type="text", nullable=true) | |
5b7da076 TC |
145 | * |
146 | * @Groups({"entries_for_user", "export_all"}) | |
34d15eb4 NL |
147 | */ |
148 | private $mimetype; | |
149 | ||
98f0929f JB |
150 | /** |
151 | * @var string | |
152 | * | |
153 | * @ORM\Column(name="language", type="text", nullable=true) | |
5b7da076 TC |
154 | * |
155 | * @Groups({"entries_for_user", "export_all"}) | |
98f0929f JB |
156 | */ |
157 | private $language; | |
158 | ||
34d15eb4 | 159 | /** |
4346a860 | 160 | * @var int |
34d15eb4 | 161 | * |
26864574 | 162 | * @ORM\Column(name="reading_time", type="integer", nullable=true) |
5b7da076 TC |
163 | * |
164 | * @Groups({"entries_for_user", "export_all"}) | |
34d15eb4 NL |
165 | */ |
166 | private $readingTime; | |
167 | ||
168 | /** | |
169 | * @var string | |
170 | * | |
171 | * @ORM\Column(name="domain_name", type="text", nullable=true) | |
5b7da076 TC |
172 | * |
173 | * @Groups({"entries_for_user", "export_all"}) | |
34d15eb4 NL |
174 | */ |
175 | private $domainName; | |
176 | ||
fad31615 JB |
177 | /** |
178 | * @var string | |
179 | * | |
180 | * @ORM\Column(name="preview_picture", type="text", nullable=true) | |
5b7da076 TC |
181 | * |
182 | * @Groups({"entries_for_user", "export_all"}) | |
fad31615 JB |
183 | */ |
184 | private $previewPicture; | |
185 | ||
34d15eb4 | 186 | /** |
4346a860 | 187 | * @var bool |
34d15eb4 NL |
188 | * |
189 | * @ORM\Column(name="is_public", type="boolean", nullable=true, options={"default" = false}) | |
5b7da076 TC |
190 | * |
191 | * @Groups({"export_all"}) | |
34d15eb4 NL |
192 | */ |
193 | private $isPublic; | |
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 | ||
5f09650e | 204 | /** |
7d1fdab2 TC |
205 | * @Exclude |
206 | * | |
1210dae1 | 207 | * @ORM\ManyToOne(targetEntity="Wallabag\UserBundle\Entity\User", inversedBy="entries") |
5b7da076 TC |
208 | * |
209 | * @Groups({"export_all"}) | |
5f09650e NL |
210 | */ |
211 | private $user; | |
212 | ||
0a018fe0 | 213 | /** |
af95c09c | 214 | * @ORM\ManyToMany(targetEntity="Tag", inversedBy="entries", cascade={"persist"}) |
e42b13bc JB |
215 | * @ORM\JoinTable( |
216 | * name="entry_tag", | |
217 | * joinColumns={ | |
206bade5 | 218 | * @ORM\JoinColumn(name="entry_id", referencedColumnName="id", onDelete="cascade") |
e42b13bc JB |
219 | * }, |
220 | * inverseJoinColumns={ | |
206bade5 | 221 | * @ORM\JoinColumn(name="tag_id", referencedColumnName="id", onDelete="cascade") |
e42b13bc JB |
222 | * } |
223 | * ) | |
0a018fe0 NL |
224 | */ |
225 | private $tags; | |
226 | ||
5f09650e NL |
227 | /* |
228 | * @param User $user | |
229 | */ | |
5d6f6f56 | 230 | public function __construct(User $user) |
5f09650e NL |
231 | { |
232 | $this->user = $user; | |
0a018fe0 | 233 | $this->tags = new ArrayCollection(); |
5f09650e NL |
234 | } |
235 | ||
9d50517c | 236 | /** |
4346a860 | 237 | * Get id. |
9d50517c | 238 | * |
4346a860 | 239 | * @return int |
9d50517c NL |
240 | */ |
241 | public function getId() | |
242 | { | |
243 | return $this->id; | |
244 | } | |
245 | ||
246 | /** | |
4346a860 JB |
247 | * Set title. |
248 | * | |
249 | * @param string $title | |
9d50517c | 250 | * |
be463487 | 251 | * @return Entry |
9d50517c NL |
252 | */ |
253 | public function setTitle($title) | |
254 | { | |
255 | $this->title = $title; | |
256 | ||
257 | return $this; | |
258 | } | |
259 | ||
260 | /** | |
4346a860 | 261 | * Get title. |
9d50517c | 262 | * |
7df80cb3 | 263 | * @return string |
9d50517c NL |
264 | */ |
265 | public function getTitle() | |
266 | { | |
267 | return $this->title; | |
268 | } | |
269 | ||
270 | /** | |
4346a860 JB |
271 | * Set url. |
272 | * | |
273 | * @param string $url | |
9d50517c | 274 | * |
be463487 | 275 | * @return Entry |
9d50517c NL |
276 | */ |
277 | public function setUrl($url) | |
278 | { | |
279 | $this->url = $url; | |
280 | ||
281 | return $this; | |
282 | } | |
283 | ||
284 | /** | |
4346a860 | 285 | * Get url. |
9d50517c | 286 | * |
7df80cb3 | 287 | * @return string |
9d50517c NL |
288 | */ |
289 | public function getUrl() | |
290 | { | |
291 | return $this->url; | |
292 | } | |
293 | ||
294 | /** | |
4346a860 JB |
295 | * Set isArchived. |
296 | * | |
8eedc8cf | 297 | * @param bool $isArchived |
9d50517c | 298 | * |
be463487 | 299 | * @return Entry |
9d50517c | 300 | */ |
905ae369 | 301 | public function setArchived($isArchived) |
9d50517c | 302 | { |
905ae369 | 303 | $this->isArchived = $isArchived; |
9d50517c NL |
304 | |
305 | return $this; | |
306 | } | |
307 | ||
308 | /** | |
4346a860 | 309 | * Get isArchived. |
9d50517c | 310 | * |
8eedc8cf | 311 | * @return bool |
9d50517c | 312 | */ |
905ae369 | 313 | public function isArchived() |
9d50517c | 314 | { |
905ae369 | 315 | return $this->isArchived; |
9d50517c NL |
316 | } |
317 | ||
189ef634 TC |
318 | /** |
319 | * @VirtualProperty | |
320 | * @SerializedName("is_archived") | |
321 | * @Groups({"entries_for_user", "export_all"}) | |
322 | */ | |
323 | public function is_Archived() | |
324 | { | |
325 | return (int) $this->isArchived(); | |
326 | } | |
327 | ||
163eae0b NL |
328 | public function toggleArchive() |
329 | { | |
905ae369 | 330 | $this->isArchived = $this->isArchived() ^ 1; |
7df80cb3 | 331 | |
163eae0b NL |
332 | return $this; |
333 | } | |
334 | ||
9d50517c | 335 | /** |
4346a860 JB |
336 | * Set isStarred. |
337 | * | |
8eedc8cf | 338 | * @param bool $isStarred |
9d50517c | 339 | * |
be463487 | 340 | * @return Entry |
9d50517c | 341 | */ |
905ae369 | 342 | public function setStarred($isStarred) |
9d50517c | 343 | { |
905ae369 | 344 | $this->isStarred = $isStarred; |
9d50517c NL |
345 | |
346 | return $this; | |
347 | } | |
348 | ||
349 | /** | |
4346a860 | 350 | * Get isStarred. |
9d50517c | 351 | * |
8eedc8cf | 352 | * @return bool |
9d50517c | 353 | */ |
905ae369 | 354 | public function isStarred() |
9d50517c | 355 | { |
905ae369 | 356 | return $this->isStarred; |
9d50517c NL |
357 | } |
358 | ||
189ef634 TC |
359 | /** |
360 | * @VirtualProperty | |
361 | * @SerializedName("is_starred") | |
362 | * @Groups({"entries_for_user", "export_all"}) | |
363 | */ | |
364 | public function is_Starred() | |
365 | { | |
366 | return (int) $this->isStarred(); | |
367 | } | |
368 | ||
163eae0b NL |
369 | public function toggleStar() |
370 | { | |
905ae369 | 371 | $this->isStarred = $this->isStarred() ^ 1; |
163eae0b NL |
372 | |
373 | return $this; | |
374 | } | |
375 | ||
9d50517c | 376 | /** |
4346a860 JB |
377 | * Set content. |
378 | * | |
379 | * @param string $content | |
9d50517c | 380 | * |
be463487 | 381 | * @return Entry |
9d50517c NL |
382 | */ |
383 | public function setContent($content) | |
384 | { | |
385 | $this->content = $content; | |
386 | ||
387 | return $this; | |
388 | } | |
389 | ||
390 | /** | |
4346a860 | 391 | * Get content. |
9d50517c | 392 | * |
7df80cb3 | 393 | * @return string |
9d50517c NL |
394 | */ |
395 | public function getContent() | |
396 | { | |
397 | return $this->content; | |
398 | } | |
399 | ||
400 | /** | |
5f09650e | 401 | * @return User |
9d50517c | 402 | */ |
5f09650e | 403 | public function getUser() |
9d50517c | 404 | { |
5f09650e | 405 | return $this->user; |
9d50517c | 406 | } |
42a90646 | 407 | |
7d1fdab2 TC |
408 | /** |
409 | * @VirtualProperty | |
410 | * @SerializedName("user_name") | |
411 | */ | |
412 | public function getUserName() | |
413 | { | |
414 | return $this->user->getUserName(); | |
415 | } | |
416 | ||
417 | /** | |
418 | * @VirtualProperty | |
419 | * @SerializedName("user_email") | |
420 | */ | |
421 | public function getUserEmail() | |
422 | { | |
423 | return $this->user->getEmail(); | |
424 | } | |
425 | ||
426 | /** | |
427 | * @VirtualProperty | |
428 | * @SerializedName("user_id") | |
429 | */ | |
430 | public function getUserId() | |
431 | { | |
432 | return $this->user->getId(); | |
433 | } | |
434 | ||
34d15eb4 | 435 | /** |
6d65c0a8 JB |
436 | * Set created_at. |
437 | * Only used when importing data from an other service. | |
438 | * | |
8664069e | 439 | * @param \DateTime $createdAt |
6d65c0a8 JB |
440 | * |
441 | * @return Entry | |
442 | */ | |
443 | public function setCreatedAt(\DateTime $createdAt) | |
444 | { | |
445 | $this->createdAt = $createdAt; | |
446 | ||
447 | return $this; | |
448 | } | |
449 | ||
450 | /** | |
8664069e | 451 | * @return \DateTime |
34d15eb4 NL |
452 | */ |
453 | public function getCreatedAt() | |
454 | { | |
455 | return $this->createdAt; | |
456 | } | |
457 | ||
34d15eb4 | 458 | /** |
8664069e | 459 | * @return \DateTime |
34d15eb4 NL |
460 | */ |
461 | public function getUpdatedAt() | |
462 | { | |
463 | return $this->updatedAt; | |
464 | } | |
465 | ||
466 | /** | |
be463487 | 467 | * @ORM\PrePersist |
34d15eb4 NL |
468 | * @ORM\PreUpdate |
469 | */ | |
be463487 | 470 | public function timestamps() |
34d15eb4 | 471 | { |
be463487 NL |
472 | if (is_null($this->createdAt)) { |
473 | $this->createdAt = new \DateTime(); | |
474 | } | |
475 | ||
34d15eb4 NL |
476 | $this->updatedAt = new \DateTime(); |
477 | } | |
478 | ||
479 | /** | |
4dc87223 | 480 | * @return ArrayCollection<Annotation> |
34d15eb4 | 481 | */ |
4dc87223 | 482 | public function getAnnotations() |
34d15eb4 | 483 | { |
4dc87223 | 484 | return $this->annotations; |
34d15eb4 NL |
485 | } |
486 | ||
487 | /** | |
4dc87223 | 488 | * @param Annotation $annotation |
34d15eb4 | 489 | */ |
4dc87223 | 490 | public function setAnnotation(Annotation $annotation) |
34d15eb4 | 491 | { |
4dc87223 | 492 | $this->annotations[] = $annotation; |
34d15eb4 NL |
493 | } |
494 | ||
495 | /** | |
496 | * @return string | |
497 | */ | |
498 | public function getMimetype() | |
499 | { | |
500 | return $this->mimetype; | |
501 | } | |
502 | ||
503 | /** | |
504 | * @param string $mimetype | |
505 | */ | |
506 | public function setMimetype($mimetype) | |
507 | { | |
508 | $this->mimetype = $mimetype; | |
509 | } | |
510 | ||
511 | /** | |
512 | * @return int | |
513 | */ | |
514 | public function getReadingTime() | |
515 | { | |
516 | return $this->readingTime; | |
517 | } | |
518 | ||
519 | /** | |
520 | * @param int $readingTime | |
521 | */ | |
522 | public function setReadingTime($readingTime) | |
523 | { | |
524 | $this->readingTime = $readingTime; | |
525 | } | |
526 | ||
527 | /** | |
528 | * @return string | |
529 | */ | |
530 | public function getDomainName() | |
531 | { | |
532 | return $this->domainName; | |
533 | } | |
534 | ||
535 | /** | |
536 | * @param string $domainName | |
537 | */ | |
538 | public function setDomainName($domainName) | |
539 | { | |
540 | $this->domainName = $domainName; | |
541 | } | |
542 | ||
543 | /** | |
4346a860 | 544 | * @return bool |
34d15eb4 | 545 | */ |
2c093b03 | 546 | public function isPublic() |
34d15eb4 NL |
547 | { |
548 | return $this->isPublic; | |
549 | } | |
550 | ||
551 | /** | |
4346a860 | 552 | * @param bool $isPublic |
34d15eb4 | 553 | */ |
82d6d9cb | 554 | public function setIsPublic($isPublic) |
34d15eb4 NL |
555 | { |
556 | $this->isPublic = $isPublic; | |
557 | } | |
0a018fe0 NL |
558 | |
559 | /** | |
560 | * @return ArrayCollection<Tag> | |
561 | */ | |
562 | public function getTags() | |
563 | { | |
564 | return $this->tags; | |
565 | } | |
566 | ||
b0458874 JB |
567 | /** |
568 | * @VirtualProperty | |
569 | * @SerializedName("tags") | |
570 | * @Groups({"entries_for_user", "export_all"}) | |
571 | */ | |
572 | public function getSerializedTags() | |
573 | { | |
574 | $data = []; | |
575 | foreach ($this->tags as $tag) { | |
576 | $data[] = $tag->getLabel(); | |
577 | } | |
578 | ||
579 | return $data; | |
580 | } | |
581 | ||
0a018fe0 NL |
582 | /** |
583 | * @param Tag $tag | |
584 | */ | |
585 | public function addTag(Tag $tag) | |
586 | { | |
625acf33 KG |
587 | if ($this->tags->contains($tag)) { |
588 | return; | |
589 | } | |
590 | ||
fc031e57 JB |
591 | // check if tag already exist but has not yet be persisted |
592 | // it seems that the previous condition with `contains()` doesn't check that case | |
593 | foreach ($this->tags as $existingTag) { | |
fc732227 | 594 | if ($existingTag->getLabel() === $tag->getLabel()) { |
fc031e57 JB |
595 | return; |
596 | } | |
597 | } | |
598 | ||
e42b13bc | 599 | $this->tags->add($tag); |
46bbd8d3 | 600 | $tag->addEntry($this); |
0a018fe0 | 601 | } |
092ca707 NL |
602 | |
603 | public function removeTag(Tag $tag) | |
604 | { | |
e42b13bc JB |
605 | if (!$this->tags->contains($tag)) { |
606 | return; | |
607 | } | |
608 | ||
092ca707 | 609 | $this->tags->removeElement($tag); |
e42b13bc | 610 | $tag->removeEntry($this); |
092ca707 | 611 | } |
fad31615 JB |
612 | |
613 | /** | |
a1413a3d | 614 | * Set previewPicture. |
fad31615 JB |
615 | * |
616 | * @param string $previewPicture | |
617 | * | |
618 | * @return Entry | |
619 | */ | |
620 | public function setPreviewPicture($previewPicture) | |
621 | { | |
622 | $this->previewPicture = $previewPicture; | |
623 | ||
624 | return $this; | |
625 | } | |
626 | ||
627 | /** | |
a1413a3d | 628 | * Get previewPicture. |
fad31615 JB |
629 | * |
630 | * @return string | |
631 | */ | |
632 | public function getPreviewPicture() | |
633 | { | |
634 | return $this->previewPicture; | |
635 | } | |
98f0929f JB |
636 | |
637 | /** | |
638 | * Set language. | |
639 | * | |
640 | * @param string $language | |
641 | * | |
642 | * @return Entry | |
643 | */ | |
644 | public function setLanguage($language) | |
645 | { | |
646 | $this->language = $language; | |
647 | ||
648 | return $this; | |
649 | } | |
650 | ||
651 | /** | |
652 | * Get language. | |
653 | * | |
654 | * @return string | |
655 | */ | |
656 | public function getLanguage() | |
657 | { | |
658 | return $this->language; | |
659 | } | |
f3d0cb91 NL |
660 | |
661 | /** | |
78b3c31d | 662 | * @return string |
f3d0cb91 | 663 | */ |
7239082a | 664 | public function getUid() |
f3d0cb91 | 665 | { |
7239082a | 666 | return $this->uid; |
f3d0cb91 NL |
667 | } |
668 | ||
669 | /** | |
7239082a | 670 | * @param string $uid |
f3d0cb91 NL |
671 | * |
672 | * @return Entry | |
673 | */ | |
7239082a | 674 | public function setUid($uid) |
f3d0cb91 | 675 | { |
7239082a | 676 | $this->uid = $uid; |
f3d0cb91 NL |
677 | |
678 | return $this; | |
679 | } | |
680 | ||
7239082a | 681 | public function generateUid() |
f3d0cb91 | 682 | { |
7239082a | 683 | if (null === $this->uid) { |
a7e2218e | 684 | // @see http://blog.kevingomez.fr/til/2015/07/26/why-is-uniqid-slow/ for true parameter |
7239082a | 685 | $this->uid = uniqid('', true); |
f3d0cb91 NL |
686 | } |
687 | } | |
f1be7af4 | 688 | |
7239082a | 689 | public function cleanUid() |
f1be7af4 | 690 | { |
7239082a | 691 | $this->uid = null; |
f1be7af4 | 692 | } |
10b35097 NL |
693 | |
694 | /** | |
695 | * @return int | |
696 | */ | |
697 | public function getHttpStatus() | |
698 | { | |
699 | return $this->httpStatus; | |
700 | } | |
701 | ||
702 | /** | |
703 | * @param int $httpStatus | |
704 | * | |
705 | * @return Entry | |
706 | */ | |
707 | public function setHttpStatus($httpStatus) | |
708 | { | |
709 | $this->httpStatus = $httpStatus; | |
710 | ||
711 | return $this; | |
712 | } | |
5e9009ce NL |
713 | |
714 | /** | |
715 | * @return \Datetime | |
716 | */ | |
717 | public function getPublishedAt() | |
718 | { | |
719 | return $this->publishedAt; | |
720 | } | |
721 | ||
722 | /** | |
723 | * @param \Datetime $publishedAt | |
724 | * | |
725 | * @return Entry | |
726 | */ | |
727 | public function setPublishedAt(\Datetime $publishedAt) | |
728 | { | |
729 | $this->publishedAt = $publishedAt; | |
730 | ||
731 | return $this; | |
732 | } | |
9d50517c | 733 | } |