Merge pull request #3128 from appwrite/feat-code-cleanup
Refactor code for locale
This commit is contained in:
commit
5593658938
1 changed files with 14 additions and 25 deletions
|
@ -1,9 +1,12 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Utopia\Database\Document;
|
|
||||||
use Appwrite\Utopia\Response;
|
use Appwrite\Utopia\Response;
|
||||||
|
use Appwrite\Utopia\Request;
|
||||||
|
use MaxMind\Db\Reader;
|
||||||
use Utopia\App;
|
use Utopia\App;
|
||||||
use Utopia\Config\Config;
|
use Utopia\Config\Config;
|
||||||
|
use Utopia\Database\Document;
|
||||||
|
use Utopia\Locale\Locale;
|
||||||
|
|
||||||
App::get('/v1/locale')
|
App::get('/v1/locale')
|
||||||
->desc('Get User Locale')
|
->desc('Get User Locale')
|
||||||
|
@ -20,11 +23,7 @@ App::get('/v1/locale')
|
||||||
->inject('response')
|
->inject('response')
|
||||||
->inject('locale')
|
->inject('locale')
|
||||||
->inject('geodb')
|
->inject('geodb')
|
||||||
->action(function ($request, $response, $locale, $geodb) {
|
->action(function (Request $request, Response $response, Locale $locale, Reader $geodb) {
|
||||||
/** @var Appwrite\Utopia\Request $request */
|
|
||||||
/** @var Appwrite\Utopia\Response $response */
|
|
||||||
/** @var Utopia\Locale\Locale $locale */
|
|
||||||
/** @var MaxMind\Db\Reader $geodb */
|
|
||||||
|
|
||||||
$eu = Config::getParam('locale-eu');
|
$eu = Config::getParam('locale-eu');
|
||||||
$currencies = Config::getParam('locale-currencies');
|
$currencies = Config::getParam('locale-currencies');
|
||||||
|
@ -82,9 +81,7 @@ App::get('/v1/locale/countries')
|
||||||
->label('sdk.response.model', Response::MODEL_COUNTRY_LIST)
|
->label('sdk.response.model', Response::MODEL_COUNTRY_LIST)
|
||||||
->inject('response')
|
->inject('response')
|
||||||
->inject('locale')
|
->inject('locale')
|
||||||
->action(function ($response, $locale) {
|
->action(function (Response $response, Locale $locale) {
|
||||||
/** @var Appwrite\Utopia\Response $response */
|
|
||||||
/** @var Utopia\Locale\Locale $locale */
|
|
||||||
|
|
||||||
$list = Config::getParam('locale-countries'); /* @var $list array */
|
$list = Config::getParam('locale-countries'); /* @var $list array */
|
||||||
$output = [];
|
$output = [];
|
||||||
|
@ -116,9 +113,7 @@ App::get('/v1/locale/countries/eu')
|
||||||
->label('sdk.response.model', Response::MODEL_COUNTRY_LIST)
|
->label('sdk.response.model', Response::MODEL_COUNTRY_LIST)
|
||||||
->inject('response')
|
->inject('response')
|
||||||
->inject('locale')
|
->inject('locale')
|
||||||
->action(function ($response, $locale) {
|
->action(function (Response $response, Locale $locale) {
|
||||||
/** @var Appwrite\Utopia\Response $response */
|
|
||||||
/** @var Utopia\Locale\Locale $locale */
|
|
||||||
|
|
||||||
$eu = Config::getParam('locale-eu');
|
$eu = Config::getParam('locale-eu');
|
||||||
$output = [];
|
$output = [];
|
||||||
|
@ -152,9 +147,7 @@ App::get('/v1/locale/countries/phones')
|
||||||
->label('sdk.response.model', Response::MODEL_PHONE_LIST)
|
->label('sdk.response.model', Response::MODEL_PHONE_LIST)
|
||||||
->inject('response')
|
->inject('response')
|
||||||
->inject('locale')
|
->inject('locale')
|
||||||
->action(function ($response, $locale) {
|
->action(function (Response $response, Locale $locale) {
|
||||||
/** @var Appwrite\Utopia\Response $response */
|
|
||||||
/** @var Utopia\Locale\Locale $locale */
|
|
||||||
|
|
||||||
$list = Config::getParam('locale-phones'); /* @var $list array */
|
$list = Config::getParam('locale-phones'); /* @var $list array */
|
||||||
$output = [];
|
$output = [];
|
||||||
|
@ -187,9 +180,7 @@ App::get('/v1/locale/continents')
|
||||||
->label('sdk.response.model', Response::MODEL_CONTINENT_LIST)
|
->label('sdk.response.model', Response::MODEL_CONTINENT_LIST)
|
||||||
->inject('response')
|
->inject('response')
|
||||||
->inject('locale')
|
->inject('locale')
|
||||||
->action(function ($response, $locale) {
|
->action(function (Response $response, Locale $locale) {
|
||||||
/** @var Appwrite\Utopia\Response $response */
|
|
||||||
/** @var Utopia\Locale\Locale $locale */
|
|
||||||
|
|
||||||
$list = Config::getParam('locale-continents'); /* @var $list array */
|
$list = Config::getParam('locale-continents'); /* @var $list array */
|
||||||
|
|
||||||
|
@ -219,8 +210,7 @@ App::get('/v1/locale/currencies')
|
||||||
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
|
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
|
||||||
->label('sdk.response.model', Response::MODEL_CURRENCY_LIST)
|
->label('sdk.response.model', Response::MODEL_CURRENCY_LIST)
|
||||||
->inject('response')
|
->inject('response')
|
||||||
->action(function ($response) {
|
->action(function (Response $response) {
|
||||||
/** @var Appwrite\Utopia\Response $response */
|
|
||||||
|
|
||||||
$list = Config::getParam('locale-currencies');
|
$list = Config::getParam('locale-currencies');
|
||||||
|
|
||||||
|
@ -242,8 +232,7 @@ App::get('/v1/locale/languages')
|
||||||
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
|
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
|
||||||
->label('sdk.response.model', Response::MODEL_LANGUAGE_LIST)
|
->label('sdk.response.model', Response::MODEL_LANGUAGE_LIST)
|
||||||
->inject('response')
|
->inject('response')
|
||||||
->action(function ($response) {
|
->action(function (Response $response) {
|
||||||
/** @var Appwrite\Utopia\Response $response */
|
|
||||||
|
|
||||||
$list = Config::getParam('locale-languages');
|
$list = Config::getParam('locale-languages');
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue