From 2b0c9a20ee8a2808b1bbf80af06e35b7de8b944e Mon Sep 17 00:00:00 2001 From: Supun Wimalasena <44988673+supun-io@users.noreply.github.com> Date: Wed, 30 Apr 2025 18:15:31 +0200 Subject: [PATCH] Update README.md with an example of Symfony PHP config --- README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/README.md b/README.md index 896832d..1ba340d 100644 --- a/README.md +++ b/README.md @@ -176,12 +176,28 @@ dunglas_doctrine_json_odm: bar: App\SomethingElse\Bar ``` +Or, the same config in PHP for better type-safety, e.g. `config/packages/doctrine_json_odm.php`: + +```php +typeMap('foo', Foo::class); + $config->typeMap('bar', Bar::class); +}; +``` + With this, `Foo` objects will be serialized as: ```json { "#type": "foo", "someProperty": "someValue" } ``` + + Another option is to use your own custom type mapper implementing `Dunglas\DoctrineJsonOdm\TypeMapperInterface`. For this, just override the service definition: ```yaml