]>
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 | ||
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 | ||
2041810a TC |
236 | /** |
237 | * @var ArrayCollection | |
238 | * @ORM\ManyToMany(targetEntity="Wallabag\GroupBundle\Entity\Group", inversedBy="presentations", cascade={"persist"}) | |
239 | */ | |
240 | private $groupShares; | |
241 | ||
5f09650e NL |
242 | /* |
243 | * @param User $user | |
244 | */ | |
5d6f6f56 | 245 | public function __construct(User $user) |
5f09650e NL |
246 | { |
247 | $this->user = $user; | |
0a018fe0 | 248 | $this->tags = new ArrayCollection(); |
5f09650e NL |
249 | } |
250 | ||
9d50517c | 251 | /** |
4346a860 | 252 | * Get id. |
9d50517c | 253 | * |
4346a860 | 254 | * @return int |
9d50517c NL |
255 | */ |
256 | public function getId() | |
257 | { | |
258 | return $this->id; | |
259 | } | |
260 | ||
261 | /** | |
4346a860 JB |
262 | * Set title. |
263 | * | |
264 | * @param string $title | |
9d50517c | 265 | * |
be463487 | 266 | * @return Entry |
9d50517c NL |
267 | */ |
268 | public function setTitle($title) | |
269 | { | |
270 | $this->title = $title; | |
271 | ||
272 | return $this; | |
273 | } | |
274 | ||
275 | /** | |
4346a860 | 276 | * Get title. |
9d50517c | 277 | * |
7df80cb3 | 278 | * @return string |
9d50517c NL |
279 | */ |
280 | public function getTitle() | |
281 | { | |
282 | return $this->title; | |
283 | } | |
284 | ||
285 | /** | |
4346a860 JB |
286 | * Set url. |
287 | * | |
288 | * @param string $url | |
9d50517c | 289 | * |
be463487 | 290 | * @return Entry |
9d50517c NL |
291 | */ |
292 | public function setUrl($url) | |
293 | { | |
294 | $this->url = $url; | |
295 | ||
296 | return $this; | |
297 | } | |
298 | ||
299 | /** | |
4346a860 | 300 | * Get url. |
9d50517c | 301 | * |
7df80cb3 | 302 | * @return string |
9d50517c NL |
303 | */ |
304 | public function getUrl() | |
305 | { | |
306 | return $this->url; | |
307 | } | |
308 | ||
309 | /** | |
4346a860 JB |
310 | * Set isArchived. |
311 | * | |
8eedc8cf | 312 | * @param bool $isArchived |
9d50517c | 313 | * |
be463487 | 314 | * @return Entry |
9d50517c | 315 | */ |
905ae369 | 316 | public function setArchived($isArchived) |
9d50517c | 317 | { |
905ae369 | 318 | $this->isArchived = $isArchived; |
9d50517c NL |
319 | |
320 | return $this; | |
321 | } | |
322 | ||
323 | /** | |
4346a860 | 324 | * Get isArchived. |
9d50517c | 325 | * |
8eedc8cf | 326 | * @return bool |
9d50517c | 327 | */ |
905ae369 | 328 | public function isArchived() |
9d50517c | 329 | { |
905ae369 | 330 | return $this->isArchived; |
9d50517c NL |
331 | } |
332 | ||
189ef634 TC |
333 | /** |
334 | * @VirtualProperty | |
335 | * @SerializedName("is_archived") | |
336 | * @Groups({"entries_for_user", "export_all"}) | |
337 | */ | |
338 | public function is_Archived() | |
339 | { | |
340 | return (int) $this->isArchived(); | |
341 | } | |
342 | ||
163eae0b NL |
343 | public function toggleArchive() |
344 | { | |
905ae369 | 345 | $this->isArchived = $this->isArchived() ^ 1; |
7df80cb3 | 346 | |
163eae0b NL |
347 | return $this; |
348 | } | |
349 | ||
9d50517c | 350 | /** |
4346a860 JB |
351 | * Set isStarred. |
352 | * | |
8eedc8cf | 353 | * @param bool $isStarred |
9d50517c | 354 | * |
be463487 | 355 | * @return Entry |
9d50517c | 356 | */ |
905ae369 | 357 | public function setStarred($isStarred) |
9d50517c | 358 | { |
905ae369 | 359 | $this->isStarred = $isStarred; |
9d50517c NL |
360 | |
361 | return $this; | |
362 | } | |
363 | ||
364 | /** | |
4346a860 | 365 | * Get isStarred. |
9d50517c | 366 | * |
8eedc8cf | 367 | * @return bool |
9d50517c | 368 | */ |
905ae369 | 369 | public function isStarred() |
9d50517c | 370 | { |
905ae369 | 371 | return $this->isStarred; |
9d50517c NL |
372 | } |
373 | ||
189ef634 TC |
374 | /** |
375 | * @VirtualProperty | |
376 | * @SerializedName("is_starred") | |
377 | * @Groups({"entries_for_user", "export_all"}) | |
378 | */ | |
379 | public function is_Starred() | |
380 | { | |
381 | return (int) $this->isStarred(); | |
382 | } | |
383 | ||
163eae0b NL |
384 | public function toggleStar() |
385 | { | |
905ae369 | 386 | $this->isStarred = $this->isStarred() ^ 1; |
163eae0b NL |
387 | |
388 | return $this; | |
389 | } | |
390 | ||
9d50517c | 391 | /** |
4346a860 JB |
392 | * Set content. |
393 | * | |
394 | * @param string $content | |
9d50517c | 395 | * |
be463487 | 396 | * @return Entry |
9d50517c NL |
397 | */ |
398 | public function setContent($content) | |
399 | { | |
400 | $this->content = $content; | |
401 | ||
402 | return $this; | |
403 | } | |
404 | ||
405 | /** | |
4346a860 | 406 | * Get content. |
9d50517c | 407 | * |
7df80cb3 | 408 | * @return string |
9d50517c NL |
409 | */ |
410 | public function getContent() | |
411 | { | |
412 | return $this->content; | |
413 | } | |
414 | ||
415 | /** | |
5f09650e | 416 | * @return User |
9d50517c | 417 | */ |
5f09650e | 418 | public function getUser() |
9d50517c | 419 | { |
5f09650e | 420 | return $this->user; |
9d50517c | 421 | } |
42a90646 | 422 | |
7d1fdab2 TC |
423 | /** |
424 | * @VirtualProperty | |
425 | * @SerializedName("user_name") | |
426 | */ | |
427 | public function getUserName() | |
428 | { | |
429 | return $this->user->getUserName(); | |
430 | } | |
431 | ||
432 | /** | |
433 | * @VirtualProperty | |
434 | * @SerializedName("user_email") | |
435 | */ | |
436 | public function getUserEmail() | |
437 | { | |
438 | return $this->user->getEmail(); | |
439 | } | |
440 | ||
441 | /** | |
442 | * @VirtualProperty | |
443 | * @SerializedName("user_id") | |
444 | */ | |
445 | public function getUserId() | |
446 | { | |
447 | return $this->user->getId(); | |
448 | } | |
449 | ||
34d15eb4 | 450 | /** |
6d65c0a8 JB |
451 | * Set created_at. |
452 | * Only used when importing data from an other service. | |
453 | * | |
8664069e | 454 | * @param \DateTime $createdAt |
6d65c0a8 JB |
455 | * |
456 | * @return Entry | |
457 | */ | |
458 | public function setCreatedAt(\DateTime $createdAt) | |
459 | { | |
460 | $this->createdAt = $createdAt; | |
461 | ||
462 | return $this; | |
463 | } | |
464 | ||
465 | /** | |
8664069e | 466 | * @return \DateTime |
34d15eb4 NL |
467 | */ |
468 | public function getCreatedAt() | |
469 | { | |
470 | return $this->createdAt; | |
471 | } | |
472 | ||
34d15eb4 | 473 | /** |
8664069e | 474 | * @return \DateTime |
34d15eb4 NL |
475 | */ |
476 | public function getUpdatedAt() | |
477 | { | |
478 | return $this->updatedAt; | |
479 | } | |
480 | ||
481 | /** | |
be463487 | 482 | * @ORM\PrePersist |
34d15eb4 NL |
483 | * @ORM\PreUpdate |
484 | */ | |
be463487 | 485 | public function timestamps() |
34d15eb4 | 486 | { |
be463487 NL |
487 | if (is_null($this->createdAt)) { |
488 | $this->createdAt = new \DateTime(); | |
489 | } | |
490 | ||
34d15eb4 NL |
491 | $this->updatedAt = new \DateTime(); |
492 | } | |
493 | ||
494 | /** | |
4dc87223 | 495 | * @return ArrayCollection<Annotation> |
34d15eb4 | 496 | */ |
4dc87223 | 497 | public function getAnnotations() |
34d15eb4 | 498 | { |
4dc87223 | 499 | return $this->annotations; |
34d15eb4 NL |
500 | } |
501 | ||
502 | /** | |
4dc87223 | 503 | * @param Annotation $annotation |
34d15eb4 | 504 | */ |
4dc87223 | 505 | public function setAnnotation(Annotation $annotation) |
34d15eb4 | 506 | { |
4dc87223 | 507 | $this->annotations[] = $annotation; |
34d15eb4 NL |
508 | } |
509 | ||
510 | /** | |
511 | * @return string | |
512 | */ | |
513 | public function getMimetype() | |
514 | { | |
515 | return $this->mimetype; | |
516 | } | |
517 | ||
518 | /** | |
519 | * @param string $mimetype | |
520 | */ | |
521 | public function setMimetype($mimetype) | |
522 | { | |
523 | $this->mimetype = $mimetype; | |
524 | } | |
525 | ||
526 | /** | |
527 | * @return int | |
528 | */ | |
529 | public function getReadingTime() | |
530 | { | |
531 | return $this->readingTime; | |
532 | } | |
533 | ||
534 | /** | |
535 | * @param int $readingTime | |
536 | */ | |
537 | public function setReadingTime($readingTime) | |
538 | { | |
539 | $this->readingTime = $readingTime; | |
540 | } | |
541 | ||
542 | /** | |
543 | * @return string | |
544 | */ | |
545 | public function getDomainName() | |
546 | { | |
547 | return $this->domainName; | |
548 | } | |
549 | ||
550 | /** | |
551 | * @param string $domainName | |
552 | */ | |
553 | public function setDomainName($domainName) | |
554 | { | |
555 | $this->domainName = $domainName; | |
556 | } | |
557 | ||
0a018fe0 | 558 | /** |
4ec53ab7 | 559 | * @return ArrayCollection |
0a018fe0 NL |
560 | */ |
561 | public function getTags() | |
562 | { | |
563 | return $this->tags; | |
564 | } | |
565 | ||
b0458874 JB |
566 | /** |
567 | * @VirtualProperty | |
568 | * @SerializedName("tags") | |
569 | * @Groups({"entries_for_user", "export_all"}) | |
570 | */ | |
571 | public function getSerializedTags() | |
572 | { | |
573 | $data = []; | |
574 | foreach ($this->tags as $tag) { | |
575 | $data[] = $tag->getLabel(); | |
576 | } | |
577 | ||
578 | return $data; | |
579 | } | |
580 | ||
0a018fe0 NL |
581 | /** |
582 | * @param Tag $tag | |
583 | */ | |
584 | public function addTag(Tag $tag) | |
585 | { | |
625acf33 KG |
586 | if ($this->tags->contains($tag)) { |
587 | return; | |
588 | } | |
589 | ||
fc031e57 JB |
590 | // check if tag already exist but has not yet be persisted |
591 | // it seems that the previous condition with `contains()` doesn't check that case | |
592 | foreach ($this->tags as $existingTag) { | |
fc732227 | 593 | if ($existingTag->getLabel() === $tag->getLabel()) { |
fc031e57 JB |
594 | return; |
595 | } | |
596 | } | |
597 | ||
e42b13bc | 598 | $this->tags->add($tag); |
46bbd8d3 | 599 | $tag->addEntry($this); |
0a018fe0 | 600 | } |
092ca707 NL |
601 | |
602 | public function removeTag(Tag $tag) | |
603 | { | |
e42b13bc JB |
604 | if (!$this->tags->contains($tag)) { |
605 | return; | |
606 | } | |
607 | ||
092ca707 | 608 | $this->tags->removeElement($tag); |
e42b13bc | 609 | $tag->removeEntry($this); |
092ca707 | 610 | } |
fad31615 JB |
611 | |
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 | } |