File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -175,6 +175,44 @@ You can pass the context like following::
175
175
DateTimeNormalizer::FORMAT_KEY => 'Y-m-d H:i:s',
176
176
]);
177
177
178
+ .. versionadded :: 5.4
179
+
180
+ The ability to configure the ``default_context `` option in the
181
+ Serializer was introduced in Symfony 5.4.
182
+
183
+ You can also configure the default context through the framework configuration:
184
+
185
+ .. configuration-block ::
186
+
187
+ .. code-block :: yaml
188
+
189
+ # config/packages/framework.yaml
190
+ framework :
191
+ # ...
192
+ serializer :
193
+ default_context :
194
+ enable_max_depth : true
195
+
196
+ .. code-block :: xml
197
+
198
+ <!-- config/packages/framework.xml -->
199
+ <framework : config >
200
+ <!-- ... -->
201
+ <framework : serializer >
202
+ <default-context enable-max-depth =" true" />
203
+ </framework : serializer >
204
+ </framework : config >
205
+
206
+ .. code-block :: php
207
+
208
+ // config/packages/framework.php
209
+ use Symfony\Config\FrameworkConfig;
210
+ use Symfony\Component\Serializer\Normalizer;
211
+
212
+ return static function (FrameworkConfig $framework) {
213
+ $framework->serializer()->defaultContext([AbstractObjectNormalizer::ENABLE_MAX_DEPTH => true]);
214
+ };
215
+
178
216
.. _serializer-using-serialization-groups-annotations :
179
217
180
218
Using Serialization Groups Annotations
You can’t perform that action at this time.
0 commit comments