Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
geocoder
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
geocoder
Commits
2026a8a7
Commit
2026a8a7
authored
1 year ago
by
Italo Mairo
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3406296
: Cache language
parent
a860b4d8
No related branches found
No related tags found
1 merge request
!39
Geocoder CacheId creation enhanced with locale parameter addition
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/ProviderBase.php
+17
-2
17 additions, 2 deletions
src/ProviderBase.php
src/ProviderUsingHandlerBase.php
+1
-4
1 addition, 4 deletions
src/ProviderUsingHandlerBase.php
with
18 additions
and
6 deletions
src/ProviderBase.php
+
17
−
2
View file @
2026a8a7
...
...
@@ -158,13 +158,28 @@ abstract class ProviderBase extends PluginBase implements ProviderInterface, Con
* the longitude.
*
* @return string
* A
n
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
();
}
}
This diff is collapsed.
Click to expand it.
src/ProviderUsingHandlerBase.php
+
1
−
4
View file @
2026a8a7
...
...
@@ -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
(),
$
l
ocale
$
this
->
getL
ocale
()
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment