Files
ABSDEV/Modules/Marketplace/Services/DependencyResolver.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

18 lines
900 B
PHP

<?php
namespace Modules\Marketplace\Services;
use Modules\Marketplace\Models\InstalledPackage;
final class DependencyResolver
{
public function __construct(private VersionConstraint $constraints=new VersionConstraint()) {}
public function resolve(array $manifest): array
{
$missing=[]; $incompatible=[];
foreach (($manifest['requires'] ?? []) as $package=>$constraint) {
$installed=InstalledPackage::query()->where('package_name',$package)->where('status','installed')->first();
if (!$installed) { $missing[$package]=$constraint; continue; }
if (!$this->constraints->matches($installed->version,(string)$constraint)) $incompatible[$package]=['required'=>$constraint,'installed'=>$installed->version];
}
return ['satisfied'=>$missing===[] && $incompatible===[],'missing'=>$missing,'incompatible'=>$incompatible];
}
}