aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Wallabag/CoreBundle/Entity/Entry.php35
-rw-r--r--src/Wallabag/CoreBundle/Helper/EntriesExport.php11
2 files changed, 42 insertions, 4 deletions
diff --git a/src/Wallabag/CoreBundle/Entity/Entry.php b/src/Wallabag/CoreBundle/Entity/Entry.php
index 9e5446a6..a2bb507e 100644
--- a/src/Wallabag/CoreBundle/Entity/Entry.php
+++ b/src/Wallabag/CoreBundle/Entity/Entry.php
@@ -6,6 +6,7 @@ use Doctrine\Common\Collections\ArrayCollection;
6use Doctrine\ORM\Mapping as ORM; 6use Doctrine\ORM\Mapping as ORM;
7use Symfony\Component\Validator\Constraints as Assert; 7use Symfony\Component\Validator\Constraints as Assert;
8use Hateoas\Configuration\Annotation as Hateoas; 8use Hateoas\Configuration\Annotation as Hateoas;
9use Symfony\Component\Serializer\Annotation\Groups;
9use JMS\Serializer\Annotation\XmlRoot; 10use JMS\Serializer\Annotation\XmlRoot;
10use Wallabag\UserBundle\Entity\User; 11use Wallabag\UserBundle\Entity\User;
11 12
@@ -27,6 +28,8 @@ class Entry
27 * @ORM\Column(name="id", type="integer") 28 * @ORM\Column(name="id", type="integer")
28 * @ORM\Id 29 * @ORM\Id
29 * @ORM\GeneratedValue(strategy="AUTO") 30 * @ORM\GeneratedValue(strategy="AUTO")
31 *
32 * @Groups({"entries_for_user", "export_all"})
30 */ 33 */
31 private $id; 34 private $id;
32 35
@@ -34,6 +37,8 @@ class Entry
34 * @var string 37 * @var string
35 * 38 *
36 * @ORM\Column(name="title", type="text", nullable=true) 39 * @ORM\Column(name="title", type="text", nullable=true)
40 *
41 * @Groups({"entries_for_user", "export_all"})
37 */ 42 */
38 private $title; 43 private $title;
39 44
@@ -42,6 +47,8 @@ class Entry
42 * 47 *
43 * @Assert\NotBlank() 48 * @Assert\NotBlank()
44 * @ORM\Column(name="url", type="text", nullable=true) 49 * @ORM\Column(name="url", type="text", nullable=true)
50 *
51 * @Groups({"entries_for_user", "export_all"})
45 */ 52 */
46 private $url; 53 private $url;
47 54
@@ -49,6 +56,8 @@ class Entry
49 * @var bool 56 * @var bool
50 * 57 *
51 * @ORM\Column(name="is_archived", type="boolean") 58 * @ORM\Column(name="is_archived", type="boolean")
59 *
60 * @Groups({"entries_for_user", "export_all"})
52 */ 61 */
53 private $isArchived = false; 62 private $isArchived = false;
54 63
@@ -56,6 +65,8 @@ class Entry
56 * @var bool 65 * @var bool
57 * 66 *
58 * @ORM\Column(name="is_starred", type="boolean") 67 * @ORM\Column(name="is_starred", type="boolean")
68 *
69 * @Groups({"entries_for_user", "export_all"})
59 */ 70 */
60 private $isStarred = false; 71 private $isStarred = false;
61 72
@@ -63,6 +74,8 @@ class Entry
63 * @var string 74 * @var string
64 * 75 *
65 * @ORM\Column(name="content", type="text", nullable=true) 76 * @ORM\Column(name="content", type="text", nullable=true)
77 *
78 * @Groups({"entries_for_user", "export_all"})
66 */ 79 */
67 private $content; 80 private $content;
68 81
@@ -70,6 +83,8 @@ class Entry
70 * @var date 83 * @var date
71 * 84 *
72 * @ORM\Column(name="created_at", type="datetime") 85 * @ORM\Column(name="created_at", type="datetime")
86 *
87 * @Groups({"export_all"})
73 */ 88 */
74 private $createdAt; 89 private $createdAt;
75 90
@@ -77,6 +92,8 @@ class Entry
77 * @var date 92 * @var date
78 * 93 *
79 * @ORM\Column(name="updated_at", type="datetime") 94 * @ORM\Column(name="updated_at", type="datetime")
95 *
96 * @Groups({"export_all"})
80 */ 97 */
81 private $updatedAt; 98 private $updatedAt;
82 99
@@ -84,6 +101,8 @@ class Entry
84 * @var string 101 * @var string
85 * 102 *
86 * @ORM\Column(name="comments", type="text", nullable=true) 103 * @ORM\Column(name="comments", type="text", nullable=true)
104 *
105 * @Groups({"export_all"})
87 */ 106 */
88 private $comments; 107 private $comments;
89 108
@@ -91,6 +110,8 @@ class Entry
91 * @var string 110 * @var string
92 * 111 *
93 * @ORM\Column(name="mimetype", type="text", nullable=true) 112 * @ORM\Column(name="mimetype", type="text", nullable=true)
113 *
114 * @Groups({"entries_for_user", "export_all"})
94 */ 115 */
95 private $mimetype; 116 private $mimetype;
96 117
@@ -98,6 +119,8 @@ class Entry
98 * @var string 119 * @var string
99 * 120 *
100 * @ORM\Column(name="language", type="text", nullable=true) 121 * @ORM\Column(name="language", type="text", nullable=true)
122 *
123 * @Groups({"entries_for_user", "export_all"})
101 */ 124 */
102 private $language; 125 private $language;
103 126
@@ -105,6 +128,8 @@ class Entry
105 * @var int 128 * @var int
106 * 129 *
107 * @ORM\Column(name="reading_time", type="integer", nullable=true) 130 * @ORM\Column(name="reading_time", type="integer", nullable=true)
131 *
132 * @Groups({"entries_for_user", "export_all"})
108 */ 133 */
109 private $readingTime; 134 private $readingTime;
110 135
@@ -112,6 +137,8 @@ class Entry
112 * @var string 137 * @var string
113 * 138 *
114 * @ORM\Column(name="domain_name", type="text", nullable=true) 139 * @ORM\Column(name="domain_name", type="text", nullable=true)
140 *
141 * @Groups({"entries_for_user", "export_all"})
115 */ 142 */
116 private $domainName; 143 private $domainName;
117 144
@@ -119,6 +146,8 @@ class Entry
119 * @var string 146 * @var string
120 * 147 *
121 * @ORM\Column(name="preview_picture", type="text", nullable=true) 148 * @ORM\Column(name="preview_picture", type="text", nullable=true)
149 *
150 * @Groups({"entries_for_user", "export_all"})
122 */ 151 */
123 private $previewPicture; 152 private $previewPicture;
124 153
@@ -126,17 +155,23 @@ class Entry
126 * @var bool 155 * @var bool
127 * 156 *
128 * @ORM\Column(name="is_public", type="boolean", nullable=true, options={"default" = false}) 157 * @ORM\Column(name="is_public", type="boolean", nullable=true, options={"default" = false})
158 *
159 * @Groups({"export_all"})
129 */ 160 */
130 private $isPublic; 161 private $isPublic;
131 162
132 /** 163 /**
133 * @ORM\ManyToOne(targetEntity="Wallabag\UserBundle\Entity\User", inversedBy="entries") 164 * @ORM\ManyToOne(targetEntity="Wallabag\UserBundle\Entity\User", inversedBy="entries")
165 *
166 * @Groups({"export_all"})
134 */ 167 */
135 private $user; 168 private $user;
136 169
137 /** 170 /**
138 * @ORM\ManyToMany(targetEntity="Tag", inversedBy="entries", cascade={"persist"}) 171 * @ORM\ManyToMany(targetEntity="Tag", inversedBy="entries", cascade={"persist"})
139 * @ORM\JoinTable 172 * @ORM\JoinTable
173 *
174 * @Groups({"entries_for_user", "export_all"})
140 */ 175 */
141 private $tags; 176 private $tags;
142 177
diff --git a/src/Wallabag/CoreBundle/Helper/EntriesExport.php b/src/Wallabag/CoreBundle/Helper/EntriesExport.php
index e073606c..f073ed7f 100644
--- a/src/Wallabag/CoreBundle/Helper/EntriesExport.php
+++ b/src/Wallabag/CoreBundle/Helper/EntriesExport.php
@@ -8,7 +8,10 @@ use Symfony\Component\HttpFoundation\Response;
8use Symfony\Component\Serializer\Serializer; 8use Symfony\Component\Serializer\Serializer;
9use Symfony\Component\Serializer\Encoder\XmlEncoder; 9use Symfony\Component\Serializer\Encoder\XmlEncoder;
10use Symfony\Component\Serializer\Encoder\JsonEncoder; 10use Symfony\Component\Serializer\Encoder\JsonEncoder;
11use Symfony\Component\Serializer\Normalizer\ObjectNormalizer; 11use Symfony\Component\Serializer\Normalizer\PropertyNormalizer;
12use Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader;
13use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory;
14use Doctrine\Common\Annotations\AnnotationReader;
12 15
13class EntriesExport 16class EntriesExport
14{ 17{
@@ -363,11 +366,11 @@ class EntriesExport
363 private function prepareSerializingContent($format) 366 private function prepareSerializingContent($format)
364 { 367 {
365 $encoders = array(new XmlEncoder(), new JsonEncoder()); 368 $encoders = array(new XmlEncoder(), new JsonEncoder());
366 $normalizers = array(new ObjectNormalizer()); 369 $classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()));
367 $normalizers[0]->setIgnoredAttributes(array('user', 'createdAt', 'updatedAt')); 370 $normalizers = array(new PropertyNormalizer($classMetadataFactory));
368 $serializer = new Serializer($normalizers, $encoders); 371 $serializer = new Serializer($normalizers, $encoders);
369 372
370 return $serializer->serialize($this->entries, $format); 373 return $serializer->serialize($this->entries, $format, array('groups' => array('entries_for_user')));
371 } 374 }
372 375
373 /** 376 /**