add set root ids

This commit is contained in:
Yisroel Baum 2026-05-25 21:42:38 +03:00
parent a87c98a729
commit 7736b88802
Signed by: yisroelbaum
GPG key ID: 0FA60884F75520A9
4 changed files with 36 additions and 3 deletions

View file

@ -2,14 +2,17 @@
namespace App\Controllers;
use App\Element\ElementRepository;
use App\Set\Set as DomainSet;
use App\Set\SetRepository;
use Illuminate\Http\JsonResponse;
class SetController
{
public function __construct(private SetRepository $setRepository)
{
public function __construct(
private SetRepository $setRepository,
private ElementRepository $elementRepository,
) {
}
public function index(): JsonResponse
@ -29,16 +32,20 @@ class SetController
* id: int,
* name: string,
* description: string,
* iconImageUrl: string
* iconImageUrl: string,
* rootElementId: int|null
* }
*/
private function buildSetPayload(DomainSet $set): array
{
$rootElement = $this->elementRepository->findRootBySet($set);
return [
'id' => $set->getId(),
'name' => $set->getName(),
'description' => $set->getDescription(),
'iconImageUrl' => $set->getIconImageUrl(),
'rootElementId' => $rootElement?->getId(),
];
}
}