forked from wallabag/wallabag
use the groups annotation instead of setIgnoredAttributes
This commit is contained in:
committed by
Nicolas Lœuillet
parent
8ac95cbfcc
commit
5b7da07620
@ -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')));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user