diff options
author | Thomas Citharel <tcit@tcit.fr> | 2015-10-19 21:17:30 +0200 |
---|---|---|
committer | Nicolas LÅ“uillet <nicolas.loeuillet@smile.fr> | 2015-11-09 16:32:48 +0100 |
commit | 268e9e7277d470dbd65b4eaa70c247ef35a95a3d (patch) | |
tree | 7667aec01d1b4989e89c54dbf79d895378d1f741 /src/Wallabag/CoreBundle | |
parent | 5b7da07620116a91d3c36ccd728d1899bc3ccb46 (diff) | |
download | wallabag-268e9e7277d470dbd65b4eaa70c247ef35a95a3d.tar.gz wallabag-268e9e7277d470dbd65b4eaa70c247ef35a95a3d.tar.zst wallabag-268e9e7277d470dbd65b4eaa70c247ef35a95a3d.zip |
use JMS Serializer
Diffstat (limited to 'src/Wallabag/CoreBundle')
-rw-r--r-- | src/Wallabag/CoreBundle/Entity/Entry.php | 2 | ||||
-rw-r--r-- | src/Wallabag/CoreBundle/Helper/EntriesExport.php | 17 |
2 files changed, 6 insertions, 13 deletions
diff --git a/src/Wallabag/CoreBundle/Entity/Entry.php b/src/Wallabag/CoreBundle/Entity/Entry.php index a2bb507e..5aa582f8 100644 --- a/src/Wallabag/CoreBundle/Entity/Entry.php +++ b/src/Wallabag/CoreBundle/Entity/Entry.php | |||
@@ -6,7 +6,7 @@ use Doctrine\Common\Collections\ArrayCollection; | |||
6 | use Doctrine\ORM\Mapping as ORM; | 6 | use Doctrine\ORM\Mapping as ORM; |
7 | use Symfony\Component\Validator\Constraints as Assert; | 7 | use Symfony\Component\Validator\Constraints as Assert; |
8 | use Hateoas\Configuration\Annotation as Hateoas; | 8 | use Hateoas\Configuration\Annotation as Hateoas; |
9 | use Symfony\Component\Serializer\Annotation\Groups; | 9 | use JMS\Serializer\Annotation\Groups; |
10 | use JMS\Serializer\Annotation\XmlRoot; | 10 | use JMS\Serializer\Annotation\XmlRoot; |
11 | use Wallabag\UserBundle\Entity\User; | 11 | use Wallabag\UserBundle\Entity\User; |
12 | 12 | ||
diff --git a/src/Wallabag/CoreBundle/Helper/EntriesExport.php b/src/Wallabag/CoreBundle/Helper/EntriesExport.php index f073ed7f..c14f9d72 100644 --- a/src/Wallabag/CoreBundle/Helper/EntriesExport.php +++ b/src/Wallabag/CoreBundle/Helper/EntriesExport.php | |||
@@ -5,13 +5,9 @@ namespace Wallabag\CoreBundle\Helper; | |||
5 | use PHPePub\Core\EPub; | 5 | use PHPePub\Core\EPub; |
6 | use PHPePub\Core\Structure\OPF\DublinCore; | 6 | use PHPePub\Core\Structure\OPF\DublinCore; |
7 | use Symfony\Component\HttpFoundation\Response; | 7 | use Symfony\Component\HttpFoundation\Response; |
8 | use Symfony\Component\Serializer\Serializer; | 8 | use JMS\Serializer; |
9 | use Symfony\Component\Serializer\Encoder\XmlEncoder; | 9 | use JMS\Serializer\SerializerBuilder; |
10 | use Symfony\Component\Serializer\Encoder\JsonEncoder; | 10 | use JMS\Serializer\SerializationContext; |
11 | use Symfony\Component\Serializer\Normalizer\PropertyNormalizer; | ||
12 | use Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader; | ||
13 | use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory; | ||
14 | use Doctrine\Common\Annotations\AnnotationReader; | ||
15 | 11 | ||
16 | class EntriesExport | 12 | class EntriesExport |
17 | { | 13 | { |
@@ -365,12 +361,9 @@ class EntriesExport | |||
365 | */ | 361 | */ |
366 | private function prepareSerializingContent($format) | 362 | private function prepareSerializingContent($format) |
367 | { | 363 | { |
368 | $encoders = array(new XmlEncoder(), new JsonEncoder()); | 364 | $serializer = SerializerBuilder::create()->build(); |
369 | $classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader())); | ||
370 | $normalizers = array(new PropertyNormalizer($classMetadataFactory)); | ||
371 | $serializer = new Serializer($normalizers, $encoders); | ||
372 | 365 | ||
373 | return $serializer->serialize($this->entries, $format, array('groups' => array('entries_for_user'))); | 366 | return $serializer->serialize($this->entries, $format, SerializationContext::create()->setGroups(array('entries_for_user'))); |
374 | } | 367 | } |
375 | 368 | ||
376 | /** | 369 | /** |