X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FCoreBundle%2FEntity%2FEntry.php;h=c3fb87d218630875e77047002fad2bad55b091d1;hb=9f0957b831622ee577fa7d8f92ec0df6f3a8e274;hp=cfb8db75275c2e42d1b994e5f037a58220bd31d5;hpb=1953a872932a63792293b4aec087880265ba89f7;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/CoreBundle/Entity/Entry.php b/src/Wallabag/CoreBundle/Entity/Entry.php index cfb8db75..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; * options={"collate"="utf8mb4_unicode_ci", "charset"="utf8mb4"}, * indexes={ * @ORM\Index(name="created_at", columns={"created_at"}), - * @ORM\Index(name="uid", columns={"uid"}) + * @ORM\Index(name="uid", columns={"uid"}), + * @ORM\Index(name="hashed_url_user_id", columns={"user_id", "hashed_url"}, options={"lengths"={null, 40}}) * } * ) * @ORM\HasLifecycleCallbacks() @@ -75,6 +76,13 @@ class Entry */ private $url; + /** + * @var string + * + * @ORM\Column(name="hashed_url", type="string", length=40, nullable=true) + */ + private $hashedUrl; + /** * @var bool * @@ -86,6 +94,15 @@ class Entry */ private $isArchived = false; + /** + * @var \DateTime + * + * @ORM\Column(name="archived_at", type="datetime", nullable=true) + * + * @Groups({"entries_for_user", "export_all"}) + */ + private $archivedAt = null; + /** * @var bool * @@ -245,6 +262,15 @@ class Entry */ private $tags; + /** + * @var string + * + * @ORM\Column(name="origin_url", type="text", nullable=true) + * + * @Groups({"entries_for_user", "export_all"}) + */ + private $originUrl; + /* * @param User $user */ @@ -298,6 +324,7 @@ class Entry public function setUrl($url) { $this->url = $url; + $this->hashedUrl = hash('sha1', $url); return $this; } @@ -326,6 +353,44 @@ class Entry return $this; } + /** + * update isArchived and archive_at fields. + * + * @param bool $isArchived + * + * @return Entry + */ + public function updateArchived($isArchived = false) + { + $this->setArchived($isArchived); + $this->setArchivedAt(null); + if ($this->isArchived()) { + $this->setArchivedAt(new \DateTime()); + } + + return $this; + } + + /** + * @return \DateTime|null + */ + public function getArchivedAt() + { + return $this->archivedAt; + } + + /** + * @param \DateTime|null $archivedAt + * + * @return Entry + */ + public function setArchivedAt($archivedAt = null) + { + $this->archivedAt = $archivedAt; + + return $this; + } + /** * Get isArchived. * @@ -348,7 +413,7 @@ class Entry public function toggleArchive() { - $this->isArchived = $this->isArchived() ^ 1; + $this->updateArchived($this->isArchived() ^ 1); return $this; } @@ -831,4 +896,48 @@ class Entry return $this; } + + /** + * Set origin url. + * + * @param string $originUrl + * + * @return Entry + */ + public function setOriginUrl($originUrl) + { + $this->originUrl = $originUrl; + + return $this; + } + + /** + * Get origin url. + * + * @return string + */ + public function getOriginUrl() + { + return $this->originUrl; + } + + /** + * @return string + */ + public function getHashedUrl() + { + return $this->hashedUrl; + } + + /** + * @param mixed $hashedUrl + * + * @return Entry + */ + public function setHashedUrl($hashedUrl) + { + $this->hashedUrl = $hashedUrl; + + return $this; + } }