File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -202,6 +202,8 @@ like the following::
202202 // For YAML
203203 // $classMetadataFactory = new ClassMetadataFactory(new YamlFileLoader('/path/to/your/definition.yml'));
204204
205+ .. _component-serializer-attributes-groups-annotations :
206+
205207Then, create your groups definition:
206208
207209.. configuration-block ::
Original file line number Diff line number Diff line change @@ -76,7 +76,7 @@ Adding Normalizers and Encoders
7676
7777.. versionadded :: 2.7
7878 The :class: `Symfony\\ Component\\ Serializer\\ Normalizer\\ ObjectNormalizer `
79- is enabled by default in Symfony 2.7. In prior versions, you need to load
79+ is enabled by default in Symfony 2.7. In prior versions, you needed to load
8080 your own normalizer.
8181
8282Once enabled, the ``serializer `` service will be available in the container
@@ -161,6 +161,15 @@ with the following configuration:
161161 ),
162162 ));
163163
164+ Next, add the :ref: `@Groups annotations <component-serializer-attributes-groups-annotations >`
165+ to your class and choose which groups to use when serializing::
166+
167+ $serializer = $this->get('serializer');
168+ $json = $serializer->serialize(
169+ $someObject,
170+ 'json', array('groups' => array('group1')
171+ );
172+
164173Enabling the Metadata Cache
165174---------------------------
166175
You can’t perform that action at this time.
0 commit comments