From c3cb5849ffc824ad6288869d07d760a7dc09f236 Mon Sep 17 00:00:00 2001 From: emilien-puget Date: Mon, 22 Sep 2014 11:59:52 +0200 Subject: [PATCH] [doc] Default group informations added informations about the Default group in the cookbook --- doc/cookbook/exclusion_strategies.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/doc/cookbook/exclusion_strategies.rst b/doc/cookbook/exclusion_strategies.rst index fa16b5fc4..87ea44ca6 100644 --- a/doc/cookbook/exclusion_strategies.rst +++ b/doc/cookbook/exclusion_strategies.rst @@ -105,6 +105,8 @@ You can achieve that by using the ``@Groups`` annotation on your properties. /** @Groups({"details"}) */ private $comments; + + private $createdAt; } You can then tell the serializer which groups to serialize in your controller:: @@ -112,6 +114,12 @@ You can then tell the serializer which groups to serialize in your controller:: use JMS\Serializer\SerializationContext; $serializer->serialize(new BlogPost(), 'json', SerializationContext::create()->setGroups(array('list'))); + + //will output $id, $title and $nbComments. + + $serializer->serialize(new BlogPost(), 'json', SerializationContext::create()->setGroups(array('Default', 'list'))); + + //will output $id, $title, $nbComments and $createdAt. Limiting serialization depth of some properties -----------------------------------------------