mirror of
https://github.com/bs-community/blessing-skin-server.git
synced 2024-12-27 06:29:19 +08:00
Allow multiple plugins market registry
This commit is contained in:
parent
bae2a5d3a8
commit
573cca5c5d
@ -105,25 +105,30 @@ class MarketController extends Controller
|
||||
{
|
||||
$registryVersion = 1;
|
||||
if (app()->environment('testing') || ! $this->registryCache) {
|
||||
try {
|
||||
$pluginsJson = $this->guzzle->request(
|
||||
'GET',
|
||||
config('plugins.registry'),
|
||||
['verify' => resource_path('misc/ca-bundle.crt')]
|
||||
)->getBody();
|
||||
} catch (Exception $e) {
|
||||
throw new Exception(trans('admin.plugins.market.connection-error', [
|
||||
'error' => htmlentities($e->getMessage()),
|
||||
]));
|
||||
}
|
||||
$registries = collect(explode(',', config('plugins.registry')));
|
||||
$this->registryCache = $registries->map(function ($registry) use ($registryVersion) {
|
||||
try {
|
||||
$pluginsJson = $this->guzzle->request(
|
||||
'GET',
|
||||
trim($registry),
|
||||
['verify' => resource_path('misc/ca-bundle.crt')]
|
||||
)->getBody();
|
||||
} catch (Exception $e) {
|
||||
throw new Exception(trans('admin.plugins.market.connection-error', [
|
||||
'error' => htmlentities($e->getMessage()),
|
||||
]));
|
||||
}
|
||||
|
||||
$this->registryCache = json_decode($pluginsJson, true);
|
||||
$received = Arr::get($this->registryCache, 'version');
|
||||
if (is_int($received) && $received != $registryVersion) {
|
||||
throw new Exception("Only version $registryVersion of market registry is accepted.");
|
||||
}
|
||||
$registryData = json_decode($pluginsJson, true);
|
||||
$received = Arr::get($registryData, 'version');
|
||||
if (is_int($received) && $received != $registryVersion) {
|
||||
throw new Exception("Only version $registryVersion of market registry is accepted.");
|
||||
}
|
||||
|
||||
return Arr::get($registryData, 'packages', []);
|
||||
})->flatten(1);
|
||||
}
|
||||
|
||||
return Arr::get($this->registryCache, 'packages', []);
|
||||
return $this->registryCache;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user