Allow multiple plugins market registry
This commit is contained in:
parent
bae2a5d3a8
commit
573cca5c5d
|
|
@ -105,25 +105,30 @@ class MarketController extends Controller
|
||||||
{
|
{
|
||||||
$registryVersion = 1;
|
$registryVersion = 1;
|
||||||
if (app()->environment('testing') || ! $this->registryCache) {
|
if (app()->environment('testing') || ! $this->registryCache) {
|
||||||
try {
|
$registries = collect(explode(',', config('plugins.registry')));
|
||||||
$pluginsJson = $this->guzzle->request(
|
$this->registryCache = $registries->map(function ($registry) use ($registryVersion) {
|
||||||
'GET',
|
try {
|
||||||
config('plugins.registry'),
|
$pluginsJson = $this->guzzle->request(
|
||||||
['verify' => resource_path('misc/ca-bundle.crt')]
|
'GET',
|
||||||
)->getBody();
|
trim($registry),
|
||||||
} catch (Exception $e) {
|
['verify' => resource_path('misc/ca-bundle.crt')]
|
||||||
throw new Exception(trans('admin.plugins.market.connection-error', [
|
)->getBody();
|
||||||
'error' => htmlentities($e->getMessage()),
|
} catch (Exception $e) {
|
||||||
]));
|
throw new Exception(trans('admin.plugins.market.connection-error', [
|
||||||
}
|
'error' => htmlentities($e->getMessage()),
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
|
||||||
$this->registryCache = json_decode($pluginsJson, true);
|
$registryData = json_decode($pluginsJson, true);
|
||||||
$received = Arr::get($this->registryCache, 'version');
|
$received = Arr::get($registryData, 'version');
|
||||||
if (is_int($received) && $received != $registryVersion) {
|
if (is_int($received) && $received != $registryVersion) {
|
||||||
throw new Exception("Only version $registryVersion of market registry is accepted.");
|
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