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