wrap set layout input
This commit is contained in:
parent
b4a2107724
commit
fac49e43d4
3 changed files with 14 additions and 3 deletions
|
|
@ -6,6 +6,7 @@ use App\Exceptions\NotFoundException;
|
||||||
use App\Set\Set;
|
use App\Set\Set;
|
||||||
use App\Set\UseCases\GetSetLayout\ElementLayoutNode;
|
use App\Set\UseCases\GetSetLayout\ElementLayoutNode;
|
||||||
use App\Set\UseCases\GetSetLayout\GetSetLayout;
|
use App\Set\UseCases\GetSetLayout\GetSetLayout;
|
||||||
|
use App\Set\UseCases\GetSetLayout\GetSetLayoutRequest;
|
||||||
use App\Set\UseCases\ListSets\ListSets;
|
use App\Set\UseCases\ListSets\ListSets;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
|
|
||||||
|
|
@ -31,7 +32,9 @@ class SetController extends Controller
|
||||||
public function show(int $setId): JsonResponse
|
public function show(int $setId): JsonResponse
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$layout = $this->getSetLayout->execute($setId);
|
$layout = $this->getSetLayout->execute(
|
||||||
|
new GetSetLayoutRequest(setId: $setId),
|
||||||
|
);
|
||||||
} catch (NotFoundException $exception) {
|
} catch (NotFoundException $exception) {
|
||||||
return new JsonResponse(
|
return new JsonResponse(
|
||||||
['error' => $exception->getMessage()],
|
['error' => $exception->getMessage()],
|
||||||
|
|
|
||||||
|
|
@ -17,9 +17,9 @@ class GetSetLayout
|
||||||
/**
|
/**
|
||||||
* @throws NotFoundException
|
* @throws NotFoundException
|
||||||
*/
|
*/
|
||||||
public function execute(int $setId): SetLayout
|
public function execute(GetSetLayoutRequest $request): SetLayout
|
||||||
{
|
{
|
||||||
$set = $this->setRepository->find($setId);
|
$set = $this->setRepository->find($request->setId);
|
||||||
if ($set === null) {
|
if ($set === null) {
|
||||||
throw new NotFoundException('set not found');
|
throw new NotFoundException('set not found');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Set\UseCases\GetSetLayout;
|
||||||
|
|
||||||
|
final readonly class GetSetLayoutRequest
|
||||||
|
{
|
||||||
|
public function __construct(public int $setId) {}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue