Skip to content

Commit

Permalink
[#5335] Minor tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
weaverryan committed Jun 28, 2015
1 parent 5123078 commit f528471
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions components/serializer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@ like the following::
// For YAML
// $classMetadataFactory = new ClassMetadataFactory(new YamlFileLoader('/path/to/your/definition.yml'));

.. _component-serializer-attributes-groups-annotations:

Then, create your groups definition:

.. configuration-block::
Expand Down
11 changes: 10 additions & 1 deletion cookbook/serializer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ Adding Normalizers and Encoders

.. versionadded:: 2.7
The :class:`Symfony\\Component\\Serializer\\Normalizer\\ObjectNormalizer`
is enabled by default in Symfony 2.7. In prior versions, you need to load
is enabled by default in Symfony 2.7. In prior versions, you needed to load
your own normalizer.

Once enabled, the ``serializer`` service will be available in the container
Expand Down Expand Up @@ -161,6 +161,15 @@ with the following configuration:
),
));
Next, add the :ref:`@Groups annotations <component-serializer-attributes-groups-annotations>`
to your class and choose which groups to use when serializing::

$serializer = $this->get('serializer');
$json = $serializer->serialize(
$someObject,
'json', array('groups' => array('group1')
);

Enabling the Metadata Cache
---------------------------

Expand Down

0 comments on commit f528471

Please sign in to comment.