feat: establish catalog identity and atomic file ownership
This commit is contained in:
1 parent
390a7a557a
commit
6b9fb54b4f
16 files changed
+1381
-23
No files matched your search
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MeshVault\Catalog;
|
||||
|
||||
use MeshVault\Repository\CatalogRepositoryInterface;
|
||||
|
||||
final class CatalogService
|
||||
{
|
||||
public function __construct(private readonly CatalogRepositoryInterface $catalog)
|
||||
{
|
||||
}
|
||||
|
||||
public function createModel(string $folderPath, string $modelName): int
|
||||
{
|
||||
return $this->catalog->atomic(fn (): int => $this->catalog->createModel($folderPath, $modelName));
|
||||
}
|
||||
|
||||
/** @return array{model: array, folder: array, files: array}|null */
|
||||
public function aggregate(int $modelId): ?array
|
||||
{
|
||||
return $this->catalog->aggregate($modelId);
|
||||
}
|
||||
|
||||
public function assignFiles(int $modelId, array $fileIds): void
|
||||
{
|
||||
$this->catalog->atomic(fn () => $this->catalog->changeFileOwner($fileIds, null, $modelId));
|
||||
}
|
||||
|
||||
public function reassignFiles(int $expectedModelId, int $targetModelId, array $fileIds): void
|
||||
{
|
||||
$this->catalog->atomic(fn () => $this->catalog->changeFileOwner($fileIds, $expectedModelId, $targetModelId));
|
||||
}
|
||||
|
||||
public function detachFiles(int $expectedModelId, array $fileIds): void
|
||||
{
|
||||
$this->catalog->atomic(fn () => $this->catalog->changeFileOwner($fileIds, $expectedModelId, null));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user