diff --git a/app/Data/ItemsCollection.php b/app/Data/ItemsCollection.php index 7d363be..0f51aa0 100644 --- a/app/Data/ItemsCollection.php +++ b/app/Data/ItemsCollection.php @@ -5,6 +5,7 @@ namespace App\Data; use App\Exceptions\ItemNotFoundException; use Illuminate\Support\Collection; use Illuminate\Support\Facades\Cache; +use Illuminate\Support\Facades\Http; use Illuminate\Support\Str; use App\Config\GiteaConfig; @@ -37,7 +38,8 @@ class ItemsCollection $rawLocalesGlobalBaseUrl = GiteaConfig::RAW_LOCALES_GLOBAL_BASE_URL; // Getting all locales in project/assets/database/locales/global from the Server development branch repository - $localesList = collect(json_decode(file_get_contents(GiteaConfig::LOCALES_GLOBAL_URL), true)); + + $localesList = collect(Http::withOptions(['verify' => false])->get(GiteaConfig::LOCALES_GLOBAL_URL)->json()); foreach ($localesList as $item) { // Extract the json name for the locale preg_match('/([a-z]{2}(-[a-z]{2})?).json/', $item['name'], $currentLocaleName, PREG_OFFSET_CAPTURE); @@ -46,7 +48,8 @@ class ItemsCollection if (empty($currentLocaleName) || !$currentLocaleName[1][0]) continue; $trimmedCurrentLocaleName = trim($currentLocaleName[1][0]); - $currentLocaleJson = json_decode(file_get_contents("${rawLocalesGlobalBaseUrl}/${trimmedCurrentLocaleName}.json"), true); + $currentLocaleJson = Http::withOptions(['verify' => false]) + ->get("${rawLocalesGlobalBaseUrl}/${trimmedCurrentLocaleName}.json")->json(); $templateLocale = collect($currentLocaleJson['templates']); $customizationLocale = collect($currentLocaleJson['customization']); $this->locales = $this->locales->merge([$trimmedCurrentLocaleName => $templateLocale->concat($customizationLocale)]); @@ -59,8 +62,9 @@ class ItemsCollection */ public function refreshItemsCache(): void { - $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))); + $this->items = collect(Http::withOptions(['verify' => false])->get(GiteaConfig::RAW_ITEMS_URL)->json()); + $this->items = $this->items->merge(collect(Http::withOptions(['verify' => false]) + ->get(GiteaConfig::RAW_CUSTOMIZATION_URL)->json())); Cache::put($this->items_cache_key, $this->items); }