@@ -43,24 +43,24 @@ public function __construct(
43
43
$ this ->manticorePort = $ manticorePort ;
44
44
}
45
45
46
- public function getSuggestionsForPlaces (string $ term ): array
46
+ public function getSuggestionsForPlaces (array $ terms ): array
47
47
{
48
- $ places = $ this ->getPlaces ($ term , 25 );
48
+ $ places = $ this ->getPlaces ($ terms , 25 );
49
49
50
50
return ['locations ' => $ places ];
51
51
}
52
52
53
- public function getSuggestionsForPlacesExact (string $ term ): array
53
+ public function getSuggestionsForPlacesExact (array $ terms ): array
54
54
{
55
- return ['locations ' => $ this ->getPlacesExact ($ term , 100 )];
55
+ return ['locations ' => $ this ->getPlacesExact ($ terms , 100 )];
56
56
}
57
57
58
- public function getSuggestionsForLocations (string $ term ): array
58
+ public function getSuggestionsForLocations (array $ terms ): array
59
59
{
60
- $ placesExact = $ this ->getPlacesExact ($ term , 10 , self ::EXACT_PLACE );
61
- $ places = $ this ->getPlaces ($ term , 20 );
62
- $ adminUnits = $ this ->getAdminUnits ($ term , 10 );
63
- $ countries = $ this ->getCountries ($ term , 5 );
60
+ $ placesExact = $ this ->getPlacesExact ($ terms , 10 , self ::EXACT_PLACE );
61
+ $ places = $ this ->getPlaces ($ terms , 20 );
62
+ $ adminUnits = $ this ->getAdminUnits ($ terms , 10 );
63
+ $ countries = $ this ->getCountries ($ terms , 5 );
64
64
$ results = array_merge ($ placesExact , $ places , $ adminUnits , $ countries );
65
65
66
66
return ['locations ' => $ this ->removeDuplicates ('id ' , $ results )];
@@ -71,10 +71,8 @@ public function getSuggestionsForLocations(string $term): array
71
71
*
72
72
* place[[, admin unit], country]
73
73
*/
74
- private function getPlacesExact (string $ term , int $ limit , ?string $ translationId = null ): array
74
+ private function getPlacesExact (array $ parts , int $ limit , ?string $ translationId = null ): array
75
75
{
76
- $ parts = array_map ('trim ' , explode (', ' , $ term ));
77
-
78
76
$ countryId = '' ;
79
77
$ adminUnits = [];
80
78
if (1 < count ($ parts )) {
@@ -128,10 +126,8 @@ private function getPlacesExact(string $term, int $limit, ?string $translationId
128
126
return $ this ->getLocationDetails ($ results , $ translationId );
129
127
}
130
128
131
- private function getPlaces (string $ term , int $ limit ): array
129
+ private function getPlaces (array $ parts , int $ limit ): array
132
130
{
133
- $ parts = array_map ('trim ' , explode (', ' , $ term ));
134
-
135
131
$ countryId = '' ;
136
132
$ adminUnits = [];
137
133
if (1 < count ($ parts )) {
@@ -181,10 +177,8 @@ private function getPlaces(string $term, int $limit): array
181
177
return $ this ->getLocationDetails ($ results , self ::PLACE );
182
178
}
183
179
184
- private function getAdminUnits (string $ term , int $ limit = 10 ): array
180
+ private function getAdminUnits (array $ parts , int $ limit = 10 ): array
185
181
{
186
- $ parts = array_map ('trim ' , explode (', ' , $ term ));
187
-
188
182
$ countryId = '' ;
189
183
$ adminUnits = [];
190
184
if (1 < count ($ parts )) {
@@ -232,10 +226,8 @@ private function getAdminUnits(string $term, int $limit = 10): array
232
226
return $ this ->getLocationDetails ($ results , self ::ADMIN_UNIT );
233
227
}
234
228
235
- private function getCountries (string $ term , int $ limit = 3 ): array
229
+ private function getCountries (array $ parts , int $ limit = 3 ): array
236
230
{
237
- $ parts = array_map ('trim ' , explode (', ' , $ term ));
238
-
239
231
if (1 !== count ($ parts )) {
240
232
return [];
241
233
}
@@ -445,7 +437,6 @@ private function getManticoreResults(Search $query, int $limit = 1000): array
445
437
446
438
private function getQueryForGeonamesRt (): Search
447
439
{
448
- $ locale = $ this ->translator ->getLocale ();
449
440
$ config = ['host ' => $ this ->manticoreHost ,'port ' => $ this ->manticorePort ];
450
441
$ client = new Client ($ config );
451
442
$ query = new Search ($ client );
0 commit comments