aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Entity/Entry.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/CoreBundle/Entity/Entry.php')
-rw-r--r--src/Wallabag/CoreBundle/Entity/Entry.php80
1 files changed, 78 insertions, 2 deletions
diff --git a/src/Wallabag/CoreBundle/Entity/Entry.php b/src/Wallabag/CoreBundle/Entity/Entry.php
index 2b1f2e05..c3fb87d2 100644
--- a/src/Wallabag/CoreBundle/Entity/Entry.php
+++ b/src/Wallabag/CoreBundle/Entity/Entry.php
@@ -25,7 +25,8 @@ use Wallabag\UserBundle\Entity\User;
25 * options={"collate"="utf8mb4_unicode_ci", "charset"="utf8mb4"}, 25 * options={"collate"="utf8mb4_unicode_ci", "charset"="utf8mb4"},
26 * indexes={ 26 * indexes={
27 * @ORM\Index(name="created_at", columns={"created_at"}), 27 * @ORM\Index(name="created_at", columns={"created_at"}),
28 * @ORM\Index(name="uid", columns={"uid"}) 28 * @ORM\Index(name="uid", columns={"uid"}),
29 * @ORM\Index(name="hashed_url_user_id", columns={"user_id", "hashed_url"}, options={"lengths"={null, 40}})
29 * } 30 * }
30 * ) 31 * )
31 * @ORM\HasLifecycleCallbacks() 32 * @ORM\HasLifecycleCallbacks()
@@ -76,6 +77,13 @@ class Entry
76 private $url; 77 private $url;
77 78
78 /** 79 /**
80 * @var string
81 *
82 * @ORM\Column(name="hashed_url", type="string", length=40, nullable=true)
83 */
84 private $hashedUrl;
85
86 /**
79 * @var bool 87 * @var bool
80 * 88 *
81 * @Exclude 89 * @Exclude
@@ -87,6 +95,15 @@ class Entry
87 private $isArchived = false; 95 private $isArchived = false;
88 96
89 /** 97 /**
98 * @var \DateTime
99 *
100 * @ORM\Column(name="archived_at", type="datetime", nullable=true)
101 *
102 * @Groups({"entries_for_user", "export_all"})
103 */
104 private $archivedAt = null;
105
106 /**
90 * @var bool 107 * @var bool
91 * 108 *
92 * @Exclude 109 * @Exclude
@@ -307,6 +324,7 @@ class Entry
307 public function setUrl($url) 324 public function setUrl($url)
308 { 325 {
309 $this->url = $url; 326 $this->url = $url;
327 $this->hashedUrl = hash('sha1', $url);
310 328
311 return $this; 329 return $this;
312 } 330 }
@@ -336,6 +354,44 @@ class Entry
336 } 354 }
337 355
338 /** 356 /**
357 * update isArchived and archive_at fields.
358 *
359 * @param bool $isArchived
360 *
361 * @return Entry
362 */
363 public function updateArchived($isArchived = false)
364 {
365 $this->setArchived($isArchived);
366 $this->setArchivedAt(null);
367 if ($this->isArchived()) {
368 $this->setArchivedAt(new \DateTime());
369 }
370
371 return $this;
372 }
373
374 /**
375 * @return \DateTime|null
376 */
377 public function getArchivedAt()
378 {
379 return $this->archivedAt;
380 }
381
382 /**
383 * @param \DateTime|null $archivedAt
384 *
385 * @return Entry
386 */
387 public function setArchivedAt($archivedAt = null)
388 {
389 $this->archivedAt = $archivedAt;
390
391 return $this;
392 }
393
394 /**
339 * Get isArchived. 395 * Get isArchived.
340 * 396 *
341 * @return bool 397 * @return bool
@@ -357,7 +413,7 @@ class Entry
357 413
358 public function toggleArchive() 414 public function toggleArchive()
359 { 415 {
360 $this->isArchived = $this->isArchived() ^ 1; 416 $this->updateArchived($this->isArchived() ^ 1);
361 417
362 return $this; 418 return $this;
363 } 419 }
@@ -864,4 +920,24 @@ class Entry
864 { 920 {
865 return $this->originUrl; 921 return $this->originUrl;
866 } 922 }
923
924 /**
925 * @return string
926 */
927 public function getHashedUrl()
928 {
929 return $this->hashedUrl;
930 }
931
932 /**
933 * @param mixed $hashedUrl
934 *
935 * @return Entry
936 */
937 public function setHashedUrl($hashedUrl)
938 {
939 $this->hashedUrl = $hashedUrl;
940
941 return $this;
942 }
867} 943}