Marketplace package catalogue
* Modules, themes, and extensions * Publisher profiles and verification metadata * Installed-package tracking * Semantic version compatibility checks * PHP, Laravel, and Content Manager compatibility checks * Dependency resolution * SHA-256 checksum validation * Package signature requirements * Installation and update history * Enable and disable controls * Removal handling * Rollback records * Licence records * Marketplace administration UI * Authenticated REST endpoints * Console audit and synchronisation commands * Permissions and sidebar integration * Feature tests
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
namespace Modules\Marketplace\Services;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
final class PackageManifest
|
||||
{
|
||||
public function parse(array|string $manifest): array
|
||||
{
|
||||
if (is_string($manifest)) {
|
||||
$decoded=json_decode($manifest,true);
|
||||
if (!is_array($decoded)) throw ValidationException::withMessages(['manifest'=>'The package manifest is not valid JSON.']);
|
||||
$manifest=$decoded;
|
||||
}
|
||||
foreach (['name','type','version'] as $field) if (!filled(Arr::get($manifest,$field))) throw ValidationException::withMessages(['manifest'=>"Manifest field [$field] is required."]);
|
||||
if (!in_array($manifest['type'],config('marketplace.supported_types',[]),true)) throw ValidationException::withMessages(['manifest'=>'Unsupported marketplace package type.']);
|
||||
$manifest['requires']=$manifest['requires'] ?? [];
|
||||
$manifest['content_manager']=$manifest['content_manager'] ?? '*';
|
||||
$manifest['laravel']=$manifest['laravel'] ?? '*';
|
||||
return $manifest;
|
||||
}
|
||||
public function fromFile(string $path): array { return $this->parse((string) file_get_contents($path)); }
|
||||
}
|
||||
Reference in New Issue
Block a user