Files
ABSDEV/Modules/Marketplace/Services/PackageManifest.php
T
Mark Gregory f09a680531 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
2026-07-24 13:49:14 +01:00

23 lines
1.2 KiB
PHP

<?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)); }
}