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