@@ -262,6 +262,7 @@ public function aggregate(array $pipeline, array $options = [])
262
262
*/
263
263
public function bulkWrite (array $ operations , array $ options = [])
264
264
{
265
+ $ options = $ this ->inheritBuilderEncoder ($ options );
265
266
$ options = $ this ->inheritWriteOptions ($ options );
266
267
$ options = $ this ->inheritCodec ($ options );
267
268
@@ -286,6 +287,7 @@ public function bulkWrite(array $operations, array $options = [])
286
287
*/
287
288
public function count (array |object $ filter = [], array $ options = [])
288
289
{
290
+ $ filter = $ this ->builderEncoder ->encodeIfSupported ($ filter );
289
291
$ options = $ this ->inheritReadOptions ($ options );
290
292
291
293
$ operation = new Count ($ this ->databaseName , $ this ->collectionName , $ filter , $ options );
@@ -307,6 +309,7 @@ public function count(array|object $filter = [], array $options = [])
307
309
*/
308
310
public function countDocuments (array |object $ filter = [], array $ options = [])
309
311
{
312
+ $ filter = $ this ->builderEncoder ->encodeIfSupported ($ filter );
310
313
$ options = $ this ->inheritReadOptions ($ options );
311
314
312
315
$ operation = new CountDocuments ($ this ->databaseName , $ this ->collectionName , $ filter , $ options );
@@ -444,6 +447,7 @@ public function createSearchIndexes(array $indexes, array $options = []): array
444
447
*/
445
448
public function deleteMany (array |object $ filter , array $ options = [])
446
449
{
450
+ $ filter = $ this ->builderEncoder ->encodeIfSupported ($ filter );
447
451
$ options = $ this ->inheritWriteOptions ($ options );
448
452
449
453
$ operation = new DeleteMany ($ this ->databaseName , $ this ->collectionName , $ filter , $ options );
@@ -465,6 +469,7 @@ public function deleteMany(array|object $filter, array $options = [])
465
469
*/
466
470
public function deleteOne (array |object $ filter , array $ options = [])
467
471
{
472
+ $ filter = $ this ->builderEncoder ->encodeIfSupported ($ filter );
468
473
$ options = $ this ->inheritWriteOptions ($ options );
469
474
470
475
$ operation = new DeleteOne ($ this ->databaseName , $ this ->collectionName , $ filter , $ options );
@@ -487,6 +492,7 @@ public function deleteOne(array|object $filter, array $options = [])
487
492
*/
488
493
public function distinct (string $ fieldName , array |object $ filter = [], array $ options = [])
489
494
{
495
+ $ filter = $ this ->builderEncoder ->encodeIfSupported ($ filter );
490
496
$ options = $ this ->inheritReadOptions ($ options );
491
497
$ options = $ this ->inheritTypeMap ($ options );
492
498
@@ -645,6 +651,7 @@ public function explain(Explainable $explainable, array $options = [])
645
651
*/
646
652
public function find (array |object $ filter = [], array $ options = [])
647
653
{
654
+ $ filter = $ this ->builderEncoder ->encodeIfSupported ($ filter );
648
655
$ options = $ this ->inheritReadOptions ($ options );
649
656
$ options = $ this ->inheritCodecOrTypeMap ($ options );
650
657
@@ -667,6 +674,7 @@ public function find(array|object $filter = [], array $options = [])
667
674
*/
668
675
public function findOne (array |object $ filter = [], array $ options = [])
669
676
{
677
+ $ filter = $ this ->builderEncoder ->encodeIfSupported ($ filter );
670
678
$ options = $ this ->inheritReadOptions ($ options );
671
679
$ options = $ this ->inheritCodecOrTypeMap ($ options );
672
680
@@ -692,6 +700,7 @@ public function findOne(array|object $filter = [], array $options = [])
692
700
*/
693
701
public function findOneAndDelete (array |object $ filter , array $ options = [])
694
702
{
703
+ $ filter = $ this ->builderEncoder ->encodeIfSupported ($ filter );
695
704
$ options = $ this ->inheritWriteOptions ($ options );
696
705
$ options = $ this ->inheritCodecOrTypeMap ($ options );
697
706
@@ -722,6 +731,7 @@ public function findOneAndDelete(array|object $filter, array $options = [])
722
731
*/
723
732
public function findOneAndReplace (array |object $ filter , array |object $ replacement , array $ options = [])
724
733
{
734
+ $ filter = $ this ->builderEncoder ->encodeIfSupported ($ filter );
725
735
$ options = $ this ->inheritWriteOptions ($ options );
726
736
$ options = $ this ->inheritCodecOrTypeMap ($ options );
727
737
@@ -752,6 +762,7 @@ public function findOneAndReplace(array|object $filter, array|object $replacemen
752
762
*/
753
763
public function findOneAndUpdate (array |object $ filter , array |object $ update , array $ options = [])
754
764
{
765
+ $ filter = $ this ->builderEncoder ->encodeIfSupported ($ filter );
755
766
$ options = $ this ->inheritWriteOptions ($ options );
756
767
$ options = $ this ->inheritCodecOrTypeMap ($ options );
757
768
@@ -1000,6 +1011,7 @@ public function rename(string $toCollectionName, ?string $toDatabaseName = null,
1000
1011
*/
1001
1012
public function replaceOne (array |object $ filter , array |object $ replacement , array $ options = [])
1002
1013
{
1014
+ $ filter = $ this ->builderEncoder ->encodeIfSupported ($ filter );
1003
1015
$ options = $ this ->inheritWriteOptions ($ options );
1004
1016
$ options = $ this ->inheritCodec ($ options );
1005
1017
@@ -1023,6 +1035,8 @@ public function replaceOne(array|object $filter, array|object $replacement, arra
1023
1035
*/
1024
1036
public function updateMany (array |object $ filter , array |object $ update , array $ options = [])
1025
1037
{
1038
+ $ filter = $ this ->builderEncoder ->encodeIfSupported ($ filter );
1039
+ $ update = $ this ->builderEncoder ->encodeIfSupported ($ update );
1026
1040
$ options = $ this ->inheritWriteOptions ($ options );
1027
1041
1028
1042
$ operation = new UpdateMany ($ this ->databaseName , $ this ->collectionName , $ filter , $ update , $ options );
@@ -1045,6 +1059,8 @@ public function updateMany(array|object $filter, array|object $update, array $op
1045
1059
*/
1046
1060
public function updateOne (array |object $ filter , array |object $ update , array $ options = [])
1047
1061
{
1062
+ $ filter = $ this ->builderEncoder ->encodeIfSupported ($ filter );
1063
+ $ update = $ this ->builderEncoder ->encodeIfSupported ($ update );
1048
1064
$ options = $ this ->inheritWriteOptions ($ options );
1049
1065
1050
1066
$ operation = new UpdateOne ($ this ->databaseName , $ this ->collectionName , $ filter , $ update , $ options );
@@ -1112,6 +1128,11 @@ public function withOptions(array $options = [])
1112
1128
return new Collection ($ this ->manager , $ this ->databaseName , $ this ->collectionName , $ options );
1113
1129
}
1114
1130
1131
+ private function inheritBuilderEncoder (array $ options ): array
1132
+ {
1133
+ return ['builderEncoder ' => $ this ->builderEncoder ] + $ options ;
1134
+ }
1135
+
1115
1136
private function inheritCodec (array $ options ): array
1116
1137
{
1117
1138
// If the options contain a type map, don't inherit anything
0 commit comments