diff options
Diffstat (limited to 'src/Wallabag/CoreBundle/Entity/Entry.php')
-rw-r--r-- | src/Wallabag/CoreBundle/Entity/Entry.php | 73 |
1 files changed, 61 insertions, 12 deletions
diff --git a/src/Wallabag/CoreBundle/Entity/Entry.php b/src/Wallabag/CoreBundle/Entity/Entry.php index c3fb87d2..4d5e6fc9 100644 --- a/src/Wallabag/CoreBundle/Entity/Entry.php +++ b/src/Wallabag/CoreBundle/Entity/Entry.php | |||
@@ -13,6 +13,7 @@ use JMS\Serializer\Annotation\XmlRoot; | |||
13 | use Symfony\Component\Validator\Constraints as Assert; | 13 | use Symfony\Component\Validator\Constraints as Assert; |
14 | use Wallabag\AnnotationBundle\Entity\Annotation; | 14 | use Wallabag\AnnotationBundle\Entity\Annotation; |
15 | use Wallabag\CoreBundle\Helper\EntityTimestampsTrait; | 15 | use Wallabag\CoreBundle\Helper\EntityTimestampsTrait; |
16 | use Wallabag\CoreBundle\Helper\UrlHasher; | ||
16 | use Wallabag\UserBundle\Entity\User; | 17 | use Wallabag\UserBundle\Entity\User; |
17 | 18 | ||
18 | /** | 19 | /** |
@@ -26,7 +27,8 @@ use Wallabag\UserBundle\Entity\User; | |||
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"}), |
29 | * @ORM\Index(name="hashed_url_user_id", columns={"user_id", "hashed_url"}, options={"lengths"={null, 40}}) | 30 | * @ORM\Index(name="hashed_url_user_id", columns={"user_id", "hashed_url"}, options={"lengths"={null, 40}}), |
31 | * @ORM\Index(name="hashed_given_url_user_id", columns={"user_id", "hashed_given_url"}, options={"lengths"={null, 40}}) | ||
30 | * } | 32 | * } |
31 | * ) | 33 | * ) |
32 | * @ORM\HasLifecycleCallbacks() | 34 | * @ORM\HasLifecycleCallbacks() |
@@ -67,6 +69,8 @@ class Entry | |||
67 | private $title; | 69 | private $title; |
68 | 70 | ||
69 | /** | 71 | /** |
72 | * Define the url fetched by wallabag (the final url after potential redirections). | ||
73 | * | ||
70 | * @var string | 74 | * @var string |
71 | * | 75 | * |
72 | * @Assert\NotBlank() | 76 | * @Assert\NotBlank() |
@@ -84,6 +88,35 @@ class Entry | |||
84 | private $hashedUrl; | 88 | private $hashedUrl; |
85 | 89 | ||
86 | /** | 90 | /** |
91 | * From where user retrieved/found the url (an other article, a twitter, or the given_url if non are provided). | ||
92 | * | ||
93 | * @var string | ||
94 | * | ||
95 | * @ORM\Column(name="origin_url", type="text", nullable=true) | ||
96 | * | ||
97 | * @Groups({"entries_for_user", "export_all"}) | ||
98 | */ | ||
99 | private $originUrl; | ||
100 | |||
101 | /** | ||
102 | * Define the url entered by the user (without redirections). | ||
103 | * | ||
104 | * @var string | ||
105 | * | ||
106 | * @ORM\Column(name="given_url", type="text", nullable=true) | ||
107 | * | ||
108 | * @Groups({"entries_for_user", "export_all"}) | ||
109 | */ | ||
110 | private $givenUrl; | ||
111 | |||
112 | /** | ||
113 | * @var string | ||
114 | * | ||
115 | * @ORM\Column(name="hashed_given_url", type="string", length=40, nullable=true) | ||
116 | */ | ||
117 | private $hashedGivenUrl; | ||
118 | |||
119 | /** | ||
87 | * @var bool | 120 | * @var bool |
88 | * | 121 | * |
89 | * @Exclude | 122 | * @Exclude |
@@ -262,15 +295,6 @@ class Entry | |||
262 | */ | 295 | */ |
263 | private $tags; | 296 | private $tags; |
264 | 297 | ||
265 | /** | ||
266 | * @var string | ||
267 | * | ||
268 | * @ORM\Column(name="origin_url", type="text", nullable=true) | ||
269 | * | ||
270 | * @Groups({"entries_for_user", "export_all"}) | ||
271 | */ | ||
272 | private $originUrl; | ||
273 | |||
274 | /* | 298 | /* |
275 | * @param User $user | 299 | * @param User $user |
276 | */ | 300 | */ |
@@ -324,7 +348,7 @@ class Entry | |||
324 | public function setUrl($url) | 348 | public function setUrl($url) |
325 | { | 349 | { |
326 | $this->url = $url; | 350 | $this->url = $url; |
327 | $this->hashedUrl = hash('sha1', $url); | 351 | $this->hashedUrl = UrlHasher::hashUrl($url); |
328 | 352 | ||
329 | return $this; | 353 | return $this; |
330 | } | 354 | } |
@@ -770,7 +794,7 @@ class Entry | |||
770 | } | 794 | } |
771 | 795 | ||
772 | /** | 796 | /** |
773 | * @return string | 797 | * @return string|null |
774 | */ | 798 | */ |
775 | public function getUid() | 799 | public function getUid() |
776 | { | 800 | { |
@@ -922,6 +946,31 @@ class Entry | |||
922 | } | 946 | } |
923 | 947 | ||
924 | /** | 948 | /** |
949 | * Set given url. | ||
950 | * | ||
951 | * @param string $givenUrl | ||
952 | * | ||
953 | * @return Entry | ||
954 | */ | ||
955 | public function setGivenUrl($givenUrl) | ||
956 | { | ||
957 | $this->givenUrl = $givenUrl; | ||
958 | $this->hashedGivenUrl = UrlHasher::hashUrl($givenUrl); | ||
959 | |||
960 | return $this; | ||
961 | } | ||
962 | |||
963 | /** | ||
964 | * Get given url. | ||
965 | * | ||
966 | * @return string | ||
967 | */ | ||
968 | public function getGivenUrl() | ||
969 | { | ||
970 | return $this->givenUrl; | ||
971 | } | ||
972 | |||
973 | /** | ||
925 | * @return string | 974 | * @return string |
926 | */ | 975 | */ |
927 | public function getHashedUrl() | 976 | public function getHashedUrl() |