55use MongoDB \Driver \ReadConcern ;
66use MongoDB \Driver \ReadPreference ;
77use MongoDB \Driver \WriteConcern ;
8- use Tequila \MongoDB \OptionsResolver \Command \AggregateResolver ;
9- use Tequila \MongoDB \OptionsResolver \Command \CountResolver ;
10- use Tequila \MongoDB \OptionsResolver \Command \CreateIndexesResolver ;
11- use Tequila \MongoDB \OptionsResolver \Command \DistinctResolver ;
12- use Tequila \MongoDB \OptionsResolver \Command \DropCollectionResolver ;
13- use Tequila \MongoDB \OptionsResolver \Command \DropIndexesResolver ;
14- use Tequila \MongoDB \OptionsResolver \Command \FindAndModifyResolver ;
158use Tequila \MongoDB \OptionsResolver \Command \FindOneAndDeleteResolver ;
169use Tequila \MongoDB \OptionsResolver \Command \FindOneAndUpdateResolver ;
1710use Tequila \MongoDB \Exception \InvalidArgumentException ;
1811use Tequila \MongoDB \Exception \UnexpectedResultException ;
1912use Tequila \MongoDB \OptionsResolver \BulkWrite \BulkWriteResolver ;
2013use Tequila \MongoDB \OptionsResolver \DatabaseOptionsResolver ;
14+ use Tequila \MongoDB \OptionsResolver \OptionsResolver ;
2115use Tequila \MongoDB \OptionsResolver \QueryOptionsResolver ;
22- use Tequila \MongoDB \OptionsResolver \ResolverFactory ;
23- use Tequila \MongoDB \Traits \CommandBuilderTrait ;
16+ use Tequila \MongoDB \Traits \CommandExecutorTrait ;
2417use Tequila \MongoDB \Traits \ExecuteCommandTrait ;
2518use Tequila \MongoDB \Write \Model \DeleteMany ;
2619use Tequila \MongoDB \Write \Model \DeleteOne ;
3629
3730class Collection
3831{
39- use CommandBuilderTrait ;
32+ use CommandExecutorTrait ;
4033 use ExecuteCommandTrait;
4134
4235 /**
@@ -87,7 +80,7 @@ public function __construct(ManagerInterface $manager, $databaseName, $collectio
8780 'writeConcern ' => $ this ->manager ->getWriteConcern (),
8881 ];
8982
90- $ options = ResolverFactory ::get (DatabaseOptionsResolver::class)->resolve ($ options );
83+ $ options = OptionsResolver ::get (DatabaseOptionsResolver::class)->resolve ($ options );
9184 $ this ->readConcern = $ options ['readConcern ' ];
9285 $ this ->readPreference = $ options ['readPreference ' ];
9386 $ this ->writeConcern = $ options ['writeConcern ' ];
@@ -106,8 +99,7 @@ public function aggregate(array $pipeline, array $options = [])
10699
107100 return $ this ->executeCommand (
108101 ['aggregate ' => $ this ->collectionName ],
109- ['pipeline ' => $ pipeline ] + $ options ,
110- AggregateResolver::class
102+ ['pipeline ' => $ pipeline ] + $ options
111103 );
112104 }
113105
@@ -150,8 +142,7 @@ public function count(array $filter = [], array $options = [])
150142 {
151143 $ cursor = $ this ->executeCommand (
152144 ['count ' => $ this ->collectionName , 'query ' => (object )$ filter ],
153- $ options ,
154- CountResolver::class
145+ $ options
155146 );
156147
157148 $ result = $ cursor ->current ();
@@ -191,8 +182,7 @@ public function createIndexes(array $indexes, array $options = [])
191182
192183 $ this ->executeCommand (
193184 ['createIndexes ' => $ this ->collectionName , 'indexes ' => $ compiledIndexes ],
194- $ options ,
195- CreateIndexesResolver::class
185+ $ options
196186 );
197187
198188 return array_map (function (Index $ index ) {
@@ -251,8 +241,7 @@ public function distinct($fieldName, array $filter = [], array $options = [])
251241
252242 $ cursor = $ this ->executeCommand (
253243 $ command ,
254- $ options ,
255- DistinctResolver::class
244+ $ options
256245 );
257246
258247 $ result = $ cursor ->current ();
@@ -273,8 +262,7 @@ public function drop(array $options = [])
273262 {
274263 $ cursor = $ this ->executeCommand (
275264 ['drop ' => $ this ->collectionName ],
276- $ options ,
277- DropCollectionResolver::class
265+ $ options
278266 );
279267
280268 return $ cursor ->current ();
@@ -290,7 +278,7 @@ public function dropIndexes(array $options = [])
290278 'dropIndexes ' => $ this ->collectionName ,
291279 'index ' => '* ' ,
292280 ];
293- $ cursor = $ this ->executeCommand ($ command , $ options, DropIndexesResolver::class );
281+ $ cursor = $ this ->executeCommand ($ command , $ options );
294282
295283 return $ cursor ->current ();
296284 }
@@ -307,7 +295,7 @@ public function dropIndex($indexName, array $options = [])
307295 'index ' => $ indexName ,
308296 ];
309297
310- $ cursor = $ this ->executeCommand ($ command , $ options, DropIndexesResolver::class );
298+ $ cursor = $ this ->executeCommand ($ command , $ options );
311299
312300 return $ cursor ->current ();
313301 }
@@ -319,7 +307,7 @@ public function dropIndex($indexName, array $options = [])
319307 */
320308 public function find (array $ filter = [], array $ options = [])
321309 {
322- $ options = ResolverFactory ::get (QueryOptionsResolver::class)->resolve ($ options );
310+ $ options = OptionsResolver ::get (QueryOptionsResolver::class)->resolve ($ options );
323311
324312 if (isset ($ options ['readPreference ' ])) {
325313 $ readPreference = $ options ['readPreference ' ];
@@ -350,9 +338,9 @@ public function findOneAndDelete(array $filter, array $options = [])
350338 'query ' => (object )$ filter ,
351339 ];
352340
353- $ options = ['remove ' => true ] + ResolverFactory ::get (FindOneAndDeleteResolver::class)->resolve ($ options );
341+ $ options = ['remove ' => true ] + OptionsResolver ::get (FindOneAndDeleteResolver::class)->resolve ($ options );
354342
355- return $ this ->executeCommand ($ command , $ options, FindAndModifyResolver::class );
343+ return $ this ->executeCommand ($ command , $ options );
356344 }
357345
358346 /**
@@ -396,10 +384,10 @@ public function findOneAndUpdate(array $filter, $update, array $options = [])
396384 'query ' => (object )$ filter ,
397385 ];
398386
399- $ options = ResolverFactory ::get (FindOneAndUpdateResolver::class)->resolve ($ options );
387+ $ options = OptionsResolver ::get (FindOneAndUpdateResolver::class)->resolve ($ options );
400388 $ options = ['update ' => (object )$ update ] + $ options ;
401389
402- return $ this ->executeCommand ($ command , $ options, FindAndModifyResolver::class );
390+ return $ this ->executeCommand ($ command , $ options );
403391 }
404392
405393 /**
@@ -526,7 +514,7 @@ public function updateOne($filter, $update, array $options = [])
526514 */
527515 private static function extractBulkWriteOptions (array $ options )
528516 {
529- $ definedOptions = ResolverFactory ::get (BulkWriteResolver::class)->getDefinedOptions ();
517+ $ definedOptions = OptionsResolver ::get (BulkWriteResolver::class)->getDefinedOptions ();
530518 array_push ($ definedOptions , 'writeConcern ' );
531519
532520 $ bulkWriteOptions = array_intersect_key ($ options , array_flip ($ definedOptions ));
0 commit comments