The Locale::setLocale and Locale::getRoute methods are supposed to be able to set the locale for HelpCenter API calls, however
setLocale relies on setting the $resourceName when Locale::getRoute is called which, with how the library is currently designed, is only re-evaluated if a RouteException is thrown and is handled by a resource trait such as FindAll.
This results in setLocale() only really being usable if the route is not explicitly defined in a setRoutes call.
Not only does setLocale have this limit in it's usability, but it also has a pretty hard to follow logic of having to rely on an exception to be thrown for it do what it's supposed to do.
How to reproduce:
$section = $client->helpCenter->categories($categoryId)->sections()->setLocale('fil')->create([
'name' => 'A section in the locale FIL',
'description' => 'A section in the locale FIL',
])
What is expected
This should make a call to
POST /api/v2/help_center/fil/categories/{$categoryId}/sections.json
What is the actual result
It instead ignores the locale and makes the call to
POST /api/v2/help_center/categories/{$categoryId}/sections.json
The
Locale::setLocale
andLocale::getRoute
methods are supposed to be able to set the locale for HelpCenter API calls, howeverLocale::getRoute
is called which, with how the library is currently designed, is only re-evaluated if aRouteException
is thrown and is handled by a resource trait such as FindAll.This results in
setLocale()
only really being usable if the route is not explicitly defined in asetRoutes
call.Not only does setLocale have this limit in it's usability, but it also has a pretty hard to follow logic of having to rely on an exception to be thrown for it do what it's supposed to do.
How to reproduce:
What is expected
This should make a call to
What is the actual result
It instead ignores the locale and makes the call to