File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed
Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change 2121use Alcaeus \MongoDbAdapter \TypeConverter ;
2222use Alcaeus \MongoDbAdapter \ExceptionConverter ;
2323use MongoDB \Driver \Exception \CommandException ;
24+ use MongoDB \Model \IndexInput ;
2425
2526/**
2627 * Represents a database collection.
@@ -597,7 +598,7 @@ public function createIndex($keys, array $options = [])
597598 }
598599
599600 if (! isset ($ options ['name ' ])) {
600- $ options ['name ' ] = \ MongoDB \generate_index_name ($ keys );
601+ $ options ['name ' ] = $ this -> generateIndexName ($ keys );
601602 }
602603
603604 $ indexes = iterator_to_array ($ this ->collection ->listIndexes ());
@@ -677,7 +678,7 @@ public function deleteIndex($keys)
677678 $ indexName .= '_1 ' ;
678679 }
679680 } elseif (is_array ($ keys )) {
680- $ indexName = \ MongoDB \generate_index_name ($ keys );
681+ $ indexName = $ this -> generateIndexName ($ keys );
681682 } else {
682683 throw new \InvalidArgumentException ();
683684 }
@@ -1039,6 +1040,18 @@ private function checkCollectionName($name)
10391040 }
10401041 }
10411042
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+
10421055 /**
10431056 * @return array
10441057 */
You can’t perform that action at this time.
0 commit comments