Skip to content

Commit f528471

Browse files
committed
[#5335] Minor tweaks
1 parent 5123078 commit f528471

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

components/serializer.rst

+2
Original file line numberDiff line numberDiff 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+
205207
Then, create your groups definition:
206208

207209
.. configuration-block::

cookbook/serializer.rst

+10-1
Original file line numberDiff line numberDiff 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

8282
Once 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+
164173
Enabling the Metadata Cache
165174
---------------------------
166175

0 commit comments

Comments
 (0)