File tree 1 file changed +15
-2
lines changed
1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change 21
21
use Alcaeus \MongoDbAdapter \TypeConverter ;
22
22
use Alcaeus \MongoDbAdapter \ExceptionConverter ;
23
23
use MongoDB \Driver \Exception \CommandException ;
24
+ use MongoDB \Model \IndexInput ;
24
25
25
26
/**
26
27
* Represents a database collection.
@@ -597,7 +598,7 @@ public function createIndex($keys, array $options = [])
597
598
}
598
599
599
600
if (! isset ($ options ['name ' ])) {
600
- $ options ['name ' ] = \ MongoDB \generate_index_name ($ keys );
601
+ $ options ['name ' ] = $ this -> generateIndexName ($ keys );
601
602
}
602
603
603
604
$ indexes = iterator_to_array ($ this ->collection ->listIndexes ());
@@ -677,7 +678,7 @@ public function deleteIndex($keys)
677
678
$ indexName .= '_1 ' ;
678
679
}
679
680
} elseif (is_array ($ keys )) {
680
- $ indexName = \ MongoDB \generate_index_name ($ keys );
681
+ $ indexName = $ this -> generateIndexName ($ keys );
681
682
} else {
682
683
throw new \InvalidArgumentException ();
683
684
}
@@ -1039,6 +1040,18 @@ private function checkCollectionName($name)
1039
1040
}
1040
1041
}
1041
1042
1043
+
1044
+ /**
1045
+ * @param array $keys Field or fields to use as index.
1046
+ * @return string
1047
+ */
1048
+ private function generateIndexName ($ keys )
1049
+ {
1050
+ $ indexInput = new IndexInput (['key ' => $ keys ]);
1051
+
1052
+ return (string ) $ indexInput ;
1053
+ }
1054
+
1042
1055
/**
1043
1056
* @return array
1044
1057
*/
You can’t perform that action at this time.
0 commit comments