aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorJeremy Benoist <jeremy.benoist@gmail.com>2016-10-02 16:06:42 +0200
committerJeremy Benoist <jeremy.benoist@gmail.com>2016-10-07 07:43:19 +0200
commitb0458874c85060c992aa1cb78dec91ee85082b74 (patch)
treece2e75fd05c22c28a79ee5dcd5f6fb72b02673b8 /src
parent9d127b3b9365c73bc393bc303545f24c159cee31 (diff)
downloadwallabag-b0458874c85060c992aa1cb78dec91ee85082b74.tar.gz
wallabag-b0458874c85060c992aa1cb78dec91ee85082b74.tar.zst
wallabag-b0458874c85060c992aa1cb78dec91ee85082b74.zip
Fix relations export for Entry
Tags & Annotations weren’t really well exported. This is now fixed (+ tests)
Diffstat (limited to 'src')
-rw-r--r--src/Wallabag/AnnotationBundle/Entity/Annotation.php7
-rw-r--r--src/Wallabag/CoreBundle/DataFixtures/ORM/LoadEntryData.php4
-rw-r--r--src/Wallabag/CoreBundle/Entity/Entry.php17
-rw-r--r--src/Wallabag/CoreBundle/Helper/EntriesExport.php12
4 files changed, 30 insertions, 10 deletions
diff --git a/src/Wallabag/AnnotationBundle/Entity/Annotation.php b/src/Wallabag/AnnotationBundle/Entity/Annotation.php
index 90ee7c2d..c48d8731 100644
--- a/src/Wallabag/AnnotationBundle/Entity/Annotation.php
+++ b/src/Wallabag/AnnotationBundle/Entity/Annotation.php
@@ -7,6 +7,7 @@ use JMS\Serializer\Annotation\ExclusionPolicy;
7use JMS\Serializer\Annotation\Exclude; 7use JMS\Serializer\Annotation\Exclude;
8use JMS\Serializer\Annotation\VirtualProperty; 8use JMS\Serializer\Annotation\VirtualProperty;
9use JMS\Serializer\Annotation\SerializedName; 9use JMS\Serializer\Annotation\SerializedName;
10use JMS\Serializer\Annotation\Groups;
10use Wallabag\UserBundle\Entity\User; 11use Wallabag\UserBundle\Entity\User;
11use Wallabag\CoreBundle\Entity\Entry; 12use Wallabag\CoreBundle\Entity\Entry;
12 13
@@ -33,6 +34,8 @@ class Annotation
33 * @var string 34 * @var string
34 * 35 *
35 * @ORM\Column(name="text", type="text") 36 * @ORM\Column(name="text", type="text")
37 *
38 * @Groups({"entries_for_user", "export_all"})
36 */ 39 */
37 private $text; 40 private $text;
38 41
@@ -54,6 +57,8 @@ class Annotation
54 * @var string 57 * @var string
55 * 58 *
56 * @ORM\Column(name="quote", type="string") 59 * @ORM\Column(name="quote", type="string")
60 *
61 * @Groups({"entries_for_user", "export_all"})
57 */ 62 */
58 private $quote; 63 private $quote;
59 64
@@ -61,6 +66,8 @@ class Annotation
61 * @var array 66 * @var array
62 * 67 *
63 * @ORM\Column(name="ranges", type="array") 68 * @ORM\Column(name="ranges", type="array")
69 *
70 * @Groups({"entries_for_user", "export_all"})
64 */ 71 */
65 private $ranges; 72 private $ranges;
66 73
diff --git a/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadEntryData.php b/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadEntryData.php
index 6c6a331a..fedad009 100644
--- a/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadEntryData.php
+++ b/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadEntryData.php
@@ -23,6 +23,9 @@ class LoadEntryData extends AbstractFixture implements OrderedFixtureInterface
23 $entry1->setContent('This is my content /o/'); 23 $entry1->setContent('This is my content /o/');
24 $entry1->setLanguage('en'); 24 $entry1->setLanguage('en');
25 25
26 $entry1->addTag($this->getReference('foo-tag'));
27 $entry1->addTag($this->getReference('baz-tag'));
28
26 $manager->persist($entry1); 29 $manager->persist($entry1);
27 30
28 $this->addReference('entry1', $entry1); 31 $this->addReference('entry1', $entry1);
@@ -96,6 +99,7 @@ class LoadEntryData extends AbstractFixture implements OrderedFixtureInterface
96 $entry6->setContent('This is my content /o/'); 99 $entry6->setContent('This is my content /o/');
97 $entry6->setArchived(true); 100 $entry6->setArchived(true);
98 $entry6->setLanguage('de'); 101 $entry6->setLanguage('de');
102 $entry6->addTag($this->getReference('bar-tag'));
99 103
100 $manager->persist($entry6); 104 $manager->persist($entry6);
101 105
diff --git a/src/Wallabag/CoreBundle/Entity/Entry.php b/src/Wallabag/CoreBundle/Entity/Entry.php
index a4b0d7a8..f2da3f4d 100644
--- a/src/Wallabag/CoreBundle/Entity/Entry.php
+++ b/src/Wallabag/CoreBundle/Entity/Entry.php
@@ -196,8 +196,6 @@ class Entry
196 * @ORM\JoinColumn(name="tag_id", referencedColumnName="id") 196 * @ORM\JoinColumn(name="tag_id", referencedColumnName="id")
197 * } 197 * }
198 * ) 198 * )
199 *
200 * @Groups({"entries_for_user", "export_all"})
201 */ 199 */
202 private $tags; 200 private $tags;
203 201
@@ -542,6 +540,21 @@ class Entry
542 } 540 }
543 541
544 /** 542 /**
543 * @VirtualProperty
544 * @SerializedName("tags")
545 * @Groups({"entries_for_user", "export_all"})
546 */
547 public function getSerializedTags()
548 {
549 $data = [];
550 foreach ($this->tags as $tag) {
551 $data[] = $tag->getLabel();
552 }
553
554 return $data;
555 }
556
557 /**
545 * @param Tag $tag 558 * @param Tag $tag
546 */ 559 */
547 public function addTag(Tag $tag) 560 public function addTag(Tag $tag)
diff --git a/src/Wallabag/CoreBundle/Helper/EntriesExport.php b/src/Wallabag/CoreBundle/Helper/EntriesExport.php
index 0c627dcd..d1f1e233 100644
--- a/src/Wallabag/CoreBundle/Helper/EntriesExport.php
+++ b/src/Wallabag/CoreBundle/Helper/EntriesExport.php
@@ -53,10 +53,6 @@ class EntriesExport
53 53
54 $this->entries = $entries; 54 $this->entries = $entries;
55 55
56 foreach ($entries as $entry) {
57 $this->tags[] = $entry->getTags();
58 }
59
60 return $this; 56 return $this;
61 } 57 }
62 58
@@ -159,8 +155,8 @@ class EntriesExport
159 155
160 // set tags as subjects 156 // set tags as subjects
161 foreach ($this->entries as $entry) { 157 foreach ($this->entries as $entry) {
162 foreach ($this->tags as $tag) { 158 foreach ($entry->getTags() as $tag) {
163 $book->setSubject($tag['value']); 159 $book->setSubject($tag->getLabel());
164 } 160 }
165 161
166 // the reader in Kobo Devices doesn't likes special caracters 162 // the reader in Kobo Devices doesn't likes special caracters
@@ -265,8 +261,8 @@ class EntriesExport
265 * Adding actual entries 261 * Adding actual entries
266 */ 262 */
267 foreach ($this->entries as $entry) { 263 foreach ($this->entries as $entry) {
268 foreach ($this->tags as $tag) { 264 foreach ($entry->getTags() as $tag) {
269 $pdf->SetKeywords($tag['value']); 265 $pdf->SetKeywords($tag->getLabel());
270 } 266 }
271 267
272 $pdf->AddPage(); 268 $pdf->AddPage();