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