Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d0743d8

Browse filesBrowse files
committed
document default context for the serializer
1 parent 91b25d7 commit d0743d8
Copy full SHA for d0743d8

File tree

2 files changed

+8
-2
lines changed
Filter options

2 files changed

+8
-2
lines changed

‎reference/configuration/framework.rst

Copy file name to clipboardExpand all lines: reference/configuration/framework.rst
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2752,6 +2752,9 @@ A map with default context options that will be used with each ``serialize`` and
27522752
call. This can be used for example to set the json encoding behavior by setting ``json_encode_options``
27532753
to a `json_encode flags bitmask`_.
27542754

2755+
You can inspect the :ref:`serializer context builders <serializer-using-context-builders>`
2756+
to discover the available settings.
2757+
27552758
.. versionadded:: 5.4
27562759

27572760
The ``default_context`` parameter was introduced in Symfony 5.4.

‎serializer.rst

Copy file name to clipboardExpand all lines: serializer.rst
+5-2Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,14 +130,15 @@ configuration:
130130
serializer:
131131
default_context:
132132
enable_max_depth: true
133+
yaml_indentation: 2
133134
134135
.. code-block:: xml
135136
136137
<!-- config/packages/framework.xml -->
137138
<framework:config>
138139
<!-- ... -->
139140
<framework:serializer>
140-
<default-context enable-max-depth="true"/>
141+
<default-context enable-max-depth="true" yaml-indentation="2"/>
141142
</framework:serializer>
142143
</framework:config>
143144
@@ -146,11 +147,13 @@ configuration:
146147
// config/packages/framework.php
147148
use Symfony\Config\FrameworkConfig;
148149
use Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer;
150+
use Symfony\Component\Serializer\Encoder\YamlEncoder;
149151
150152
return static function (FrameworkConfig $framework) {
151153
$framework->serializer()
152154
->defaultContext([
153-
AbstractObjectNormalizer::ENABLE_MAX_DEPTH => true
155+
AbstractObjectNormalizer::ENABLE_MAX_DEPTH => true,
156+
YamlEncoder::YAML_INDENTATION => 2,
154157
])
155158
;
156159
};

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.