8000 [Waiting Code Merge] Update reference/configuration/framework.rst for new serializer service by loalf · Pull Request #1829 · symfony/symfony-docs · GitHub
[go: up one dir, main page]

Skip to content

[Waiting Code Merge] Update reference/configuration/framework.rst for new serializer service #1829

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Mar 30, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
8000
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions reference/configuration/framework.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ Configuration
* field_name
* `session`_
* `lifetime`_
* `serializer`_
* enabled
* `templating`_
* `assets_base_urls`_
* `assets_version`_
Expand Down Expand Up @@ -112,6 +114,36 @@ lifetime
This determines the lifetime of the session - in seconds. By default it will use
``0``, which means the cookie is valid for the length of the browser session.

serializer
~~~~~~~~~~

enabled
.......

**type**: ``boolean`` **default**: ``false``

Whether to enable or not the serializer service in the service container. If enabled,
the serializer will be loaded along with two encoders (:class:`Symfony\\Component\\Serializer\\Encoder\\JsonEncoder`
and :class:`Symfony\\Component\\Serializer\\Encoder\\XmlEncoder`)
but none normalizer. The :class:`Symfony\\Component\\Serializer\\Normalizer\\GetSetMethodNormalizer` is broken by design
so you are required to load it under your responsability.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably provide the configuration to enable this service. That would also serve as a generic example.

You can load more normalizers and/or encoders by tagging them as ``serializer.encoder`` and
``serializer.normalizer``. It's also possible to set the priority of the tag in order to decide the
matching order.

Here an example on how to load the load
the :class:`Symfony\\Component\\Serializer\\Normalizer\\GetSetMethodNormalizer`:

.. code-block:: yaml

# app/config/config.yml
services:
get_set_method_normalizer:
class: Symfony\\Component\\Serializer\\Normalizer\\GetSetMethodNormalizer
tags:
- { name: serializer.normalizer }

templating
~~~~~~~~~~

Expand Down Expand Up @@ -319,6 +351,10 @@ Full Default Configuration
# DEPRECATED! Please use: cookie_httponly
httponly: ~

# serializer configuration
serializer:
enabled: false

# templating configuration
templating:
assets_version: ~
Expand Down
22 changes: 22 additions & 0 deletions reference/dic_tags.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ the AsseticBundle has several tags that aren't listed here.
+-----------------------------------+---------------------------------------------------------------------------+
| `security.listener.factory`_ | Necessary when creating a custom authentication system |
+-----------------------------------+---------------------------------------------------------------------------+
| `serializer.encoder`_ | Register a new encoder in the Serializer service |
+-----------------------------------+---------------------------------------------------------------------------+
| `serializer.normalizer`_ | Register a new normalizer in the Serializer service |
+-----------------------------------+---------------------------------------------------------------------------+
| `swiftmailer.plugin`_ | Register a custom SwiftMailer Plugin |
+-----------------------------------+---------------------------------------------------------------------------+
| `templating.helper`_ | Make your service available in PHP templates |
Expand Down Expand Up @@ -558,6 +562,24 @@ is used behind the scenes to determine if the user should have access. The

For more information, read the cookbook article: :doc:`/cookbook/security/voters`.

serializer.encoder
------------------

**Purpose**: Register a new encoder in the Serializer service

You have to enable the Serializer service in order to use this tag. The class to
be tagged should extend the :class:`Symfony\\Component\\Serializer\\Encoder\\EncoderInterface`
and :class:`Symfony\\Component\\Serializer\\Encoder\\DecoderInterface`

serializer.normalizer
---------------------

**Purpose**: Register a new normalizer in the Serializer service

You have to enable the Serializer service in order to use this tag. The class to
be tagged should extend the :class:`Symfony\\Component\\Serializer\\Normalizer\\NormalizerInterface`
and :class:`Symfony\\Component\\Serializer\\Normalizer\\DenormalizerInterface`

swiftmailer.plugin
------------------

Expand Down
0