mirror of
https://github.com/sp-tarkov/forge.git
synced 2025-02-12 20:20:41 -05:00
Refringe
db578071e4
This update gives mod versions a supported SPT version field that accepts a semantic version. The latest supported SPT version will be automatically resolved based on the semvar. Next up: I need to update the ModVersion to SptVersion relationship to be a many-to-many and expand the resolution to resolve multiple versions.
45 lines
889 B
PHP
45 lines
889 B
PHP
<?php
|
|
|
|
namespace App\Observers;
|
|
|
|
use App\Models\ModVersion;
|
|
use App\Services\SptVersionService;
|
|
|
|
class SptVersionObserver
|
|
{
|
|
protected SptVersionService $sptVersionService;
|
|
|
|
public function __construct(SptVersionService $sptVersionService)
|
|
{
|
|
$this->sptVersionService = $sptVersionService;
|
|
}
|
|
|
|
/**
|
|
* Handle the SptVersion "saved" event.
|
|
*/
|
|
public function saved(): void
|
|
{
|
|
$this->resolveSptVersion();
|
|
}
|
|
|
|
/**
|
|
* Resolve the SptVersion's dependencies.
|
|
*/
|
|
private function resolveSptVersion(): void
|
|
{
|
|
$modVersions = ModVersion::all();
|
|
|
|
foreach ($modVersions as $modVersion) {
|
|
$this->sptVersionService->resolve($modVersion);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Handle the SptVersion "deleted" event.
|
|
*/
|
|
public function deleted(): void
|
|
{
|
|
$this->resolveSptVersion();
|
|
}
|
|
}
|