aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Entity/Entry.php
diff options
context:
space:
mode:
authorJérémy Benoist <j0k3r@users.noreply.github.com>2019-05-29 11:14:00 +0200
committerGitHub <noreply@github.com>2019-05-29 11:14:00 +0200
commit73ec68b1ffafb792265a3805833e5cd84c966aed (patch)
tree33c6040c050f85c537f8dbf5e91d8c281db092cd /src/Wallabag/CoreBundle/Entity/Entry.php
parent2ba365c7c49556cd23b444dc3bb8d4a8cf08809d (diff)
parent2cbee36a0184786644470a84fdd8c720cfcac58e (diff)
downloadwallabag-73ec68b1ffafb792265a3805833e5cd84c966aed.tar.gz
wallabag-73ec68b1ffafb792265a3805833e5cd84c966aed.tar.zst
wallabag-73ec68b1ffafb792265a3805833e5cd84c966aed.zip
Merge pull request #3984 from wallabag/2.4
Merge 2.4 into master
Diffstat (limited to 'src/Wallabag/CoreBundle/Entity/Entry.php')
-rw-r--r--src/Wallabag/CoreBundle/Entity/Entry.php81
1 files changed, 79 insertions, 2 deletions
diff --git a/src/Wallabag/CoreBundle/Entity/Entry.php b/src/Wallabag/CoreBundle/Entity/Entry.php
index 2b1f2e05..1b4367fd 100644
--- a/src/Wallabag/CoreBundle/Entity/Entry.php
+++ b/src/Wallabag/CoreBundle/Entity/Entry.php
@@ -13,6 +13,7 @@ use JMS\Serializer\Annotation\XmlRoot;
13use Symfony\Component\Validator\Constraints as Assert; 13use Symfony\Component\Validator\Constraints as Assert;
14use Wallabag\AnnotationBundle\Entity\Annotation; 14use Wallabag\AnnotationBundle\Entity\Annotation;
15use Wallabag\CoreBundle\Helper\EntityTimestampsTrait; 15use Wallabag\CoreBundle\Helper\EntityTimestampsTrait;
16use Wallabag\CoreBundle\Helper\UrlHasher;
16use Wallabag\UserBundle\Entity\User; 17use Wallabag\UserBundle\Entity\User;
17 18
18/** 19/**
@@ -25,7 +26,8 @@ use Wallabag\UserBundle\Entity\User;
25 * options={"collate"="utf8mb4_unicode_ci", "charset"="utf8mb4"}, 26 * options={"collate"="utf8mb4_unicode_ci", "charset"="utf8mb4"},
26 * indexes={ 27 * indexes={
27 * @ORM\Index(name="created_at", columns={"created_at"}), 28 * @ORM\Index(name="created_at", columns={"created_at"}),
28 * @ORM\Index(name="uid", columns={"uid"}) 29 * @ORM\Index(name="uid", columns={"uid"}),
30 * @ORM\Index(name="hashed_url_user_id", columns={"user_id", "hashed_url"}, options={"lengths"={null, 40}})
29 * } 31 * }
30 * ) 32 * )
31 * @ORM\HasLifecycleCallbacks() 33 * @ORM\HasLifecycleCallbacks()
@@ -76,6 +78,13 @@ class Entry
76 private $url; 78 private $url;
77 79
78 /** 80 /**
81 * @var string
82 *
83 * @ORM\Column(name="hashed_url", type="string", length=40, nullable=true)
84 */
85 private $hashedUrl;
86
87 /**
79 * @var bool 88 * @var bool
80 * 89 *
81 * @Exclude 90 * @Exclude
@@ -87,6 +96,15 @@ class Entry
87 private $isArchived = false; 96 private $isArchived = false;
88 97
89 /** 98 /**
99 * @var \DateTime
100 *
101 * @ORM\Column(name="archived_at", type="datetime", nullable=true)
102 *
103 * @Groups({"entries_for_user", "export_all"})
104 */
105 private $archivedAt = null;
106
107 /**
90 * @var bool 108 * @var bool
91 * 109 *
92 * @Exclude 110 * @Exclude
@@ -307,6 +325,7 @@ class Entry
307 public function setUrl($url) 325 public function setUrl($url)
308 { 326 {
309 $this->url = $url; 327 $this->url = $url;
328 $this->hashedUrl = UrlHasher::hashUrl($url);
310 329
311 return $this; 330 return $this;
312 } 331 }
@@ -336,6 +355,44 @@ class Entry
336 } 355 }
337 356
338 /** 357 /**
358 * update isArchived and archive_at fields.
359 *
360 * @param bool $isArchived
361 *
362 * @return Entry
363 */
364 public function updateArchived($isArchived = false)
365 {
366 $this->setArchived($isArchived);
367 $this->setArchivedAt(null);
368 if ($this->isArchived()) {
369 $this->setArchivedAt(new \DateTime());
370 }
371
372 return $this;
373 }
374
375 /**
376 * @return \DateTime|null
377 */
378 public function getArchivedAt()
379 {
380 return $this->archivedAt;
381 }
382
383 /**
384 * @param \DateTime|null $archivedAt
385 *
386 * @return Entry
387 */
388 public function setArchivedAt($archivedAt = null)
389 {
390 $this->archivedAt = $archivedAt;
391
392 return $this;
393 }
394
395 /**
339 * Get isArchived. 396 * Get isArchived.
340 * 397 *
341 * @return bool 398 * @return bool
@@ -357,7 +414,7 @@ class Entry
357 414
358 public function toggleArchive() 415 public function toggleArchive()
359 { 416 {
360 $this->isArchived = $this->isArchived() ^ 1; 417 $this->updateArchived($this->isArchived() ^ 1);
361 418
362 return $this; 419 return $this;
363 } 420 }
@@ -864,4 +921,24 @@ class Entry
864 { 921 {
865 return $this->originUrl; 922 return $this->originUrl;
866 } 923 }
924
925 /**
926 * @return string
927 */
928 public function getHashedUrl()
929 {
930 return $this->hashedUrl;
931 }
932
933 /**
934 * @param mixed $hashedUrl
935 *
936 * @return Entry
937 */
938 public function setHashedUrl($hashedUrl)
939 {
940 $this->hashedUrl = $hashedUrl;
941
942 return $this;
943 }
867} 944}