feat: Adding customization data

This commit is contained in:
Mangiang 2021-10-12 00:06:29 -04:00
parent 7e95c3bf16
commit fe5daaded8
2 changed files with 4 additions and 2 deletions

View File

@ -4,6 +4,7 @@ namespace App\Config;
final class GiteaConfig { final class GiteaConfig {
public const RAW_ITEMS_URL = 'https://dev.sp-tarkov.com/SPT-AKI/Server/raw/branch/development/project/assets/database/templates/items.json'; public const RAW_ITEMS_URL = 'https://dev.sp-tarkov.com/SPT-AKI/Server/raw/branch/development/project/assets/database/templates/items.json';
public const RAW_CUSTOMIZATION_URL = 'https://dev.sp-tarkov.com/SPT-AKI/Server/raw/branch/development/project/assets/database/templates/customization.json';
public const LOCALES_GLOBAL_URL = 'https://dev.sp-tarkov.com/api/v1/repos/SPT-AKI/Server/contents/project%2Fassets%2Fdatabase%2Flocales%2Fglobal'; public const LOCALES_GLOBAL_URL = 'https://dev.sp-tarkov.com/api/v1/repos/SPT-AKI/Server/contents/project%2Fassets%2Fdatabase%2Flocales%2Fglobal';
public const RAW_LOCALES_GLOBAL_BASE_URL = 'https://dev.sp-tarkov.com/SPT-AKI/Server/raw/branch/development/project/assets/database/locales/global/'; public const RAW_LOCALES_GLOBAL_BASE_URL = 'https://dev.sp-tarkov.com/SPT-AKI/Server/raw/branch/development/project/assets/database/locales/global/';
} }

View File

@ -44,14 +44,15 @@ class ItemsCollection
if (empty($current_locale_name) || !$current_locale_name[1][0]) continue; if (empty($current_locale_name) || !$current_locale_name[1][0]) continue;
$trimmed_current_locale_name = trim($current_locale_name[1][0]); $trimmed_current_locale_name = trim($current_locale_name[1][0]);
$current_locale = collect([$trimmed_current_locale_name => json_decode(file_get_contents("${raw_locales_global_base_url}/${trimmed_current_locale_name}.json"), true)['templates']]); $current_locale_json = json_decode(file_get_contents("${raw_locales_global_base_url}/${trimmed_current_locale_name}.json"), true);
$this->locales = $this->locales->merge($current_locale); $this->locales = $this->locales->merge([$trimmed_current_locale_name => [collect($current_locale_json['templates'])->merge(collect($current_locale_json['customization']))]]);
} }
Cache::put($this->locales_cache_key, $this->locales); Cache::put($this->locales_cache_key, $this->locales);
} }
public function refreshItemsCache(): void { public function refreshItemsCache(): void {
$this->items = collect(json_decode(file_get_contents(GiteaConfig::RAW_ITEMS_URL), true)); $this->items = collect(json_decode(file_get_contents(GiteaConfig::RAW_ITEMS_URL), true));
$this->items = $this->items->merge(collect(json_decode(file_get_contents(GiteaConfig::RAW_CUSTOMIZATION_URL), true)));
Cache::put($this->items_cache_key, $this->items); Cache::put($this->items_cache_key, $this->items);
} }