This commit is contained in:
Marek Lenczewski
2026-03-31 08:48:24 +02:00
parent f9a9004fcd
commit 576bfed36d
26 changed files with 203 additions and 253 deletions

View File

@@ -5,7 +5,6 @@ namespace App\Controller\Api;
use App\DTO\Request\UpdateTaskRequest;
use App\Entity\Task;
use App\Service\TaskManager;
use App\Service\TaskSerializer;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response;
@@ -17,23 +16,20 @@ class TaskController extends AbstractController
{
public function __construct(
private TaskManager $taskManager,
private TaskSerializer $taskSerializer,
) {}
#[Route('/{id}', name: 'show', methods: ['GET'])]
public function show(Task $task): JsonResponse
{
$response = $this->taskSerializer->serializeTask($task);
return $this->json($response);
return $this->json($task, context: ['groups' => ['task:read', 'category:read']]);
}
#[Route('/{id}', name: 'update', methods: ['PUT'])]
public function update(#[MapRequestPayload] UpdateTaskRequest $dto, Task $task): JsonResponse
{
$result = $this->taskManager->updateTask($task, $dto);
$task = $this->taskManager->updateTask($task, $dto);
return $this->json($result);
return $this->json($task, context: ['groups' => ['task:read', 'category:read']]);
}
#[Route('/{id}', name: 'delete', methods: ['DELETE'])]

View File

@@ -41,7 +41,7 @@ class TaskSchemaController extends AbstractController
$startParam = $request->query->get('start');
$start = $startParam ? new \DateTimeImmutable($startParam) : new \DateTimeImmutable('today');
return $this->json($this->taskViewBuilder->buildWeekView($start));
return $this->json($this->taskViewBuilder->buildWeekView($start), context: ['groups' => ['task:read', 'category:read']]);
}
#[Route('/all', name: 'schemas.all', methods: ['GET'])]
@@ -55,7 +55,7 @@ class TaskSchemaController extends AbstractController
#[Route('/all-tasks', name: 'schemas.allTasks', methods: ['GET'])]
public function allTasks(): JsonResponse
{
return $this->json($this->taskViewBuilder->buildAllTasksView());
return $this->json($this->taskViewBuilder->buildAllTasksView(), context: ['groups' => ['task:read', 'category:read']]);
}
#[Route('/{id}', name: 'schemas.show', methods: ['GET'])]