You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: register DateTimeNormalizer by default (#119)
* Add a note about DateTimeNormalizer in README
Without it, serializing DateTimeInterface instances leads to huge serialized data.
* Register the DateTimeNormalizer in the Symfony bundle
* minor tweaks
---------
Co-authored-by: Kévin Dunglas <[email protected]>
new Serializer([new ArrayDenormalizer(), new ObjectNormalizer()], [new JsonEncoder()])
50
+
new Serializer([new BackedEnumNormalizer(), new DateTimeNormalizer(), new ArrayDenormalizer(), new ObjectNormalizer()], [new JsonEncoder()])
49
51
);
50
52
}
51
53
@@ -214,7 +216,6 @@ For using the built-in type mapper:
214
216
);
215
217
```
216
218
217
-
218
219
### Limitations when updating nested properties
219
220
220
221
Due to how Doctrine works, it will not detect changes to nested objects or properties.
@@ -291,21 +292,23 @@ class Kernel extends BaseKernel
291
292
292
293
**How can I add additional normalizers?**
293
294
294
-
The Symfony Serializer is easily extensible. This bundle registers and uses a service with ID `dunglas_doctrine_json_odm.serializer` as the serializer for the JSON type. This means we can easily override it in our `services.yaml` to use additional normalizers.
295
-
As an example we use the Symfony `DateTimeNormalizer` service, so we do have support for any property that is an instance of `\DateTimeInterface`. Be aware that the order of the normalizers might be relevant depending on the normalizers you use.
295
+
The Symfony Serializer is easily extensible. This bundle registers and uses a service with ID `dunglas_doctrine_json_odm.serializer` as the serializer for the JSON type.
296
+
This means we can easily override it in our `services.yaml` to use additional normalizers.
297
+
As an example we inject a custom normalizer service. Be aware that the order of the normalizers might be relevant depending on the normalizers you use.
296
298
297
299
```yaml
298
300
# Add DateTime Normalizer to Dunglas' Doctrine JSON ODM Bundle
As a side note: If you happen to use [Autowiring](https://symfony.com/doc/current/service_container/autowiring.html) in your `services.yaml` you might need to set `autowire: false` too. Same goes for `autoconfigure: false` in case you're using [Autoconfiguration](https://symfony.com/doc/current/service_container.html#the-autoconfigure-option).
308
-
309
312
**When the namespace of a used entity changes**
310
313
311
314
For classes without [type aliases](#using-type-aliases), because we store the `#type` along with the data in the database, you have to migrate the already existing data in your database to reflect the new namespace.
@@ -321,7 +324,7 @@ WHERE 'AppBundle\\\Entity\\\Bar' = JSON_EXTRACT(misc, '$."#type"');
321
324
322
325
## Credits
323
326
324
-
This bundle is brought to you by [Kévin Dunglas](https://dunglas.fr) and [awesome contributors](https://github.com/dunglas/doctrine-json-odm/graphs/contributors).
327
+
This bundle is brought to you by [Kévin Dunglas](https://dunglas.dev) and [awesome contributors](https://github.com/dunglas/doctrine-json-odm/graphs/contributors).
325
328
Sponsored by [Les-Tilleuls.coop](https://les-tilleuls.coop).
0 commit comments