File tree Expand file tree Collapse file tree 1 file changed +4
-5
lines changed
Expand file tree Collapse file tree 1 file changed +4
-5
lines changed Original file line number Diff line number Diff line change 2727use MongoDB \Exception \InvalidArgumentException ;
2828use MongoDB \Exception \UnexpectedValueException ;
2929use MongoDB \Exception \UnsupportedException ;
30- use MongoDB \Model \TypeMapArrayIterator ;
3130use ArrayIterator ;
3231use stdClass ;
3332use Traversable ;
@@ -280,16 +279,16 @@ public function execute(Server $server)
280279 return $ cursor ;
281280 }
282281
282+ if (isset ($ this ->options ['typeMap ' ])) {
283+ $ cursor ->setTypeMap (\MongoDB \create_field_path_type_map ($ this ->options ['typeMap ' ], 'result.$ ' ));
284+ }
285+
283286 $ result = current ($ cursor ->toArray ());
284287
285288 if ( ! isset ($ result ->result ) || ! is_array ($ result ->result )) {
286289 throw new UnexpectedValueException ('aggregate command did not return a "result" array ' );
287290 }
288291
289- if (isset ($ this ->options ['typeMap ' ])) {
290- return new TypeMapArrayIterator ($ result ->result , $ this ->options ['typeMap ' ]);
291- }
292-
293292 return new ArrayIterator ($ result ->result );
294293 }
295294
You can’t perform that action at this time.
0 commit comments