110 Parents $parentResultCollection,
114 if($collection->
count() <= 0)
119 $candidatesTypes = [];
122 for($i = 0, $l = $collection->
count(); $i < $l; $i++)
124 $candidate = $collection[$i];
126 if($location->
getExternalId() === $candidate->getExternalId())
131 $candidateType = $candidate->getType();
133 if($candidateType ===
Location\Type::UNKNOWN)
138 if($location->
getType() !== Location\Type::UNKNOWN && $candidate->getType() >= $location->
getType())
149 if(in_array($candidateType, $parentTypes,
true))
154 $candidatesTypes[] = [$i, $candidateType];
157 if(count($candidatesTypes) <= 0)
162 if(count($candidatesTypes) > 1)
164 $typeColumn = array_column($candidatesTypes, 1);
165 array_multisort($typeColumn, SORT_ASC, $candidatesTypes);
168 return $collection[$candidatesTypes[0][0]];
183 ->setDescendant($location);
190 $rawData = $this->
find(
191 new Requesters\
ByIdRequester($this->httpClient, $this->cachePool),
195 'language' => $languageId
200 $ancestorsRawData = $ancestorDataConverter->convert($rawData, $location->
getType());
205 foreach ($ancestorsRawData as $data)
212 'query' => $data[
'NAME'],
214 'location' => $latLon,
215 'language' => $languageId
231 $result->addItem($localParent);
233 if ($llParents = $localParent->getParents())
235 foreach ($llParents as $localParent)
237 $result->addItem($localParent);
247 $parentSource->getExternalId(),
254 $result->addItem($detailedParent);