1
0
Fork 0
mirror of synced 2024-07-03 21:50:34 +12:00

Merge pull request #3128 from appwrite/feat-code-cleanup

Refactor code for locale
This commit is contained in:
Eldad A. Fux 2022-05-02 10:56:21 +03:00 committed by GitHub
commit 5593658938
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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,12 +23,8 @@ 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');
$output = []; $output = [];
@ -82,10 +81,8 @@ 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,10 +147,8 @@ 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');