Skip to content

Commit cd5c197

Browse files
committed
minor #17305 improve documentation of default_context for the serializer (dbu)
This PR was merged into the 6.2 branch. Discussion ---------- improve documentation of default_context for the serializer additional info for #17310 fix #17306 the code example will only work once symfony/symfony#47243 is merged Commits ------- 852aa11 document default context for the serializer
2 parents 725d856 + 852aa11 commit cd5c197

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

reference/configuration/framework.rst

+3
Original file line numberDiff line numberDiff line change
@@ -2764,6 +2764,9 @@ A map with default context options that will be used with each ``serialize`` and
27642764
call. This can be used for example to set the json encoding behavior by setting ``json_encode_options``
27652765
to a `json_encode flags bitmask`_.
27662766

2767+
You can inspect the :ref:`serializer context builders <serializer-using-context-builders>`
2768+
to discover the available settings.
2769+
27672770
php_errors
27682771
~~~~~~~~~~
27692772

serializer.rst

+5-2
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)