File tree Expand file tree Collapse file tree 3 files changed +46
-3
lines changed
src/Bundle/Resources/config Expand file tree Collapse file tree 3 files changed +46
-3
lines changed Original file line number Diff line number Diff line change @@ -250,7 +250,7 @@ As an example we use the Symfony `DateTimeNormalizer` service so we do have supp
250
250
dunglas_doctrine_json_odm.serializer :
251
251
class : Dunglas\DoctrineJsonOdm\Serializer
252
252
arguments :
253
- - ['@serializer.denormalizer .array', '@serializer.normalizer.datetime', '@serializer .normalizer.object']
253
+ - ['@dunglas_doctrine_json_odm.normalizer .array', '@serializer.normalizer.datetime', '@dunglas_doctrine_json_odm .normalizer.object']
254
254
- ['@serializer.encoder.json']
255
255
public : true
256
256
` ` `
Original file line number Diff line number Diff line change 5
5
xsi : schemaLocation =" http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd" >
6
6
7
7
<services >
8
+ <service id =" dunglas_doctrine_json_odm.normalizer.object" class =" Symfony\Component\Serializer\Normalizer\ObjectNormalizer" public =" false" >
9
+ <argument type =" service" id =" serializer.mapping.class_metadata_factory" on-invalid =" ignore" />
10
+ <argument >null</argument ><!-- name converter -->
11
+ <argument type =" service" id =" serializer.property_accessor" />
12
+ <argument type =" service" id =" property_info" on-invalid =" ignore" />
13
+ <argument type =" service" id =" serializer.mapping.class_discriminator_resolver" on-invalid =" ignore" />
14
+ </service >
15
+
16
+ <service id =" dunglas_doctrine_json_odm.normalizer.array" class =" Symfony\Component\Serializer\Normalizer\ArrayDenormalizer" public =" false" />
17
+
8
18
<service id =" dunglas_doctrine_json_odm.serializer" class =" Dunglas\DoctrineJsonOdm\Serializer" public =" true" >
9
19
<argument type =" collection" >
10
- <argument type =" service" id =" serializer.denormalizer .array" />
11
- <argument type =" service" id =" serializer .normalizer.object" />
20
+ <argument type =" service" id =" dunglas_doctrine_json_odm.normalizer .array" />
21
+ <argument type =" service" id =" dunglas_doctrine_json_odm .normalizer.object" />
12
22
</argument >
13
23
14
24
<argument type =" collection" >
Original file line number Diff line number Diff line change @@ -162,4 +162,37 @@ public function testNullIsStoredAsNull()
162
162
163
163
$ this ->assertNull ($ stmt ->fetch ()['attributes ' ]);
164
164
}
165
+
166
+ public function testStoreAndRetrieveDocumentWithInstantiatedOtherSerializer ()
167
+ {
168
+ /**
169
+ * This call is necessary to cover this issue.
170
+ *
171
+ * @see https://github.com/dunglas/doctrine-json-odm/pull/78
172
+ */
173
+ $ serializer = self ::$ kernel ->getContainer ()->get ('serializer ' );
174
+
175
+ $ attribute1 = new Attribute ();
176
+ $ attribute1 ->key = 'foo ' ;
177
+ $ attribute1 ->value = 'bar ' ;
178
+
179
+ $ attribute2 = new Attribute ();
180
+ $ attribute2 ->key = 'weights ' ;
181
+ $ attribute2 ->value = [34 , 67 ];
182
+
183
+ $ attributes = [$ attribute1 , $ attribute2 ];
184
+
185
+ $ product = new Product ();
186
+ $ product ->name = 'My product ' ;
187
+ $ product ->attributes = $ attributes ;
188
+
189
+ $ manager = self ::$ kernel ->getContainer ()->get ('doctrine ' )->getManagerForClass (Product::class);
190
+ $ manager ->persist ($ product );
191
+ $ manager ->flush ();
192
+
193
+ $ manager ->clear ();
194
+
195
+ $ retrievedProduct = $ manager ->find (Product::class, $ product ->id );
196
+ $ this ->assertEquals ($ attributes , $ retrievedProduct ->attributes );
197
+ }
165
198
}
You can’t perform that action at this time.
0 commit comments