File tree 2 files changed +12
-1
lines changed
2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -202,6 +202,8 @@ like the following::
202
202
// For YAML
203
203
// $classMetadataFactory = new ClassMetadataFactory(new YamlFileLoader('/path/to/your/definition.yml'));
204
204
205
+ .. _component-serializer-attributes-groups-annotations :
206
+
205
207
Then, create your groups definition:
206
208
207
209
.. configuration-block ::
Original file line number Diff line number Diff line change @@ -76,7 +76,7 @@ Adding Normalizers and Encoders
76
76
77
77
.. versionadded :: 2.7
78
78
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
80
80
your own normalizer.
81
81
82
82
Once enabled, the ``serializer `` service will be available in the container
@@ -161,6 +161,15 @@ with the following configuration:
161
161
),
162
162
));
163
163
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
+
164
173
Enabling the Metadata Cache
165
174
---------------------------
166
175
You can’t perform that action at this time.
0 commit comments