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 @@ -120,6 +120,49 @@ You can pass the context as follows::
120120 DateTimeNormalizer::FORMAT_KEY => 'Y-m-d H:i:s',
121121 ]);
122122
123+ You can also configure the default context through the framework
124+ configuration:
125+
126+ .. configuration-block ::
127+
128+ .. code-block :: yaml
129+
130+ # config/packages/framework.yaml
131+ framework :
132+ # ...
133+ serializer :
134+ default_context :
135+ enable_max_depth : true
136+
137+ .. code-block :: xml
138+
139+ <!-- config/packages/framework.xml -->
140+ <framework : config >
141+ <!-- ... -->
142+ <framework : serializer >
143+ <default-context enable-max-depth =" true" />
144+ </framework : serializer >
145+ </framework : config >
146+
147+ .. code-block :: php
148+
149+ // config/packages/framework.php
150+ use Symfony\Config\FrameworkConfig;
151+ use Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer;
152+
153+ return static function (FrameworkConfig $framework) {
154+ $framework->serializer()
155+ ->defaultContext([
156+ AbstractObjectNormalizer::ENABLE_MAX_DEPTH => true
157+ ])
158+ ;
159+ };
160+
161+ .. versionadded :: 5.4
162+
163+ The ability to configure the ``default_context `` option in the
164+ Serializer was introduced in Symfony 5.4.
165+
123166.. _serializer-using-serialization-groups-annotations :
124167
125168Using Serialization Groups Annotations
You can’t perform that action at this time.
0 commit comments