]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/CoreBundle/Helper/EntriesExport.php
use the groups annotation instead of setIgnoredAttributes
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Helper / EntriesExport.php
index e073606cf9dfe155df5f9d176f4f3f243efc6896..f073ed7f46447b655d8459fd0fe1c81e6d1198f9 100644 (file)
@@ -8,7 +8,10 @@ use Symfony\Component\HttpFoundation\Response;
 use Symfony\Component\Serializer\Serializer;
 use Symfony\Component\Serializer\Encoder\XmlEncoder;
 use Symfony\Component\Serializer\Encoder\JsonEncoder;
-use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
+use Symfony\Component\Serializer\Normalizer\PropertyNormalizer;
+use Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader;
+use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory;
+use Doctrine\Common\Annotations\AnnotationReader;
 
 class EntriesExport
 {
@@ -363,11 +366,11 @@ class EntriesExport
     private function prepareSerializingContent($format)
     {
         $encoders = array(new XmlEncoder(), new JsonEncoder());
-        $normalizers = array(new ObjectNormalizer());
-        $normalizers[0]->setIgnoredAttributes(array('user', 'createdAt', 'updatedAt'));
+        $classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()));
+        $normalizers = array(new PropertyNormalizer($classMetadataFactory));
         $serializer = new Serializer($normalizers, $encoders);
 
-        return $serializer->serialize($this->entries, $format);
+        return $serializer->serialize($this->entries, $format, array('groups' => array('entries_for_user')));
     }
 
     /**