Skip to content
Snippets Groups Projects
Commit 2026a8a7 authored by Italo Mairo's avatar Italo Mairo
Browse files

Issue #3406296: Cache language

parent a860b4d8
No related branches found
No related tags found
1 merge request!39Geocoder CacheId creation enhanced with locale parameter addition
......@@ -158,13 +158,28 @@ abstract class ProviderBase extends PluginBase implements ProviderInterface, Con
* the longitude.
*
* @return string
* An unique cache id.
* A unique cache id.
*/
protected function getCacheId($method, array $data): string {
// Set cache id also on the basis of the locale/language param (#3406296).
$locale = $this->getLocale();
$cid = [$method, $this->getPluginId()];
$cid[] = sha1(serialize($this->configuration) . serialize($data));
$cid[] = sha1(serialize($this->configuration) . serialize($data) . $locale);
return implode(':', $cid);
}
/**
* Set the Locale/language parameter for Geocoding/Reverse-Geocoding ops.
*
* Define it on the basis of the geocoder additional option,
* or falling back to the current Interface language code/id.
*
* @return string
* The locale id.
*/
protected function getLocale(): string {
return !empty($this->configuration['geocoder']['locale']) ? $this->configuration['geocoder']['locale'] : $this->languageManager->getCurrentLanguage()->getId();
}
}
......@@ -98,13 +98,10 @@ abstract class ProviderUsingHandlerBase extends ProviderBase {
* @throws \ReflectionException
*/
protected function getHandlerWrapper(): StatefulGeocoder {
// Define the locale on the basis of the geocoder additional option,
// or falling back to the current Interface language code/id.
$locale = !empty($this->configuration['geocoder']['locale']) ? $this->configuration['geocoder']['locale'] : $this->languageManager->getCurrentLanguage()->getId();
if ($this->handlerWrapper === NULL) {
$this->handlerWrapper = new StatefulGeocoder(
$this->getHandler(),
$locale
$this->getLocale()
);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment