update
This commit is contained in:
@@ -52,10 +52,10 @@ class CategoryController extends AbstractController
|
||||
}
|
||||
|
||||
#[Route('/{id}', name: 'delete', methods: ['DELETE'])]
|
||||
public function delete(Category $category): Response
|
||||
public function delete(Category $category): JsonResponse
|
||||
{
|
||||
$this->categoryManager->deleteCategory($category);
|
||||
|
||||
return new Response(status: Response::HTTP_NO_CONTENT);
|
||||
return $this->json(null, Response::HTTP_NO_CONTENT);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,10 +37,10 @@ class TaskController extends AbstractController
|
||||
}
|
||||
|
||||
#[Route('/{id}', name: 'delete', methods: ['DELETE'])]
|
||||
public function delete(Task $task): Response
|
||||
public function delete(Task $task): JsonResponse
|
||||
{
|
||||
$this->taskManager->deleteTask($task);
|
||||
|
||||
return new Response(status: Response::HTTP_NO_CONTENT);
|
||||
return $this->json(null, Response::HTTP_NO_CONTENT);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ use App\DTO\Request\ToggleRequest;
|
||||
use App\DTO\Request\UpdateSchemaRequest;
|
||||
use App\Entity\TaskSchema;
|
||||
use App\Repository\TaskSchemaRepository;
|
||||
use App\Service\TaskManager;
|
||||
use App\Service\TaskSchemaManager;
|
||||
use App\Service\TaskViewBuilder;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
@@ -22,10 +23,11 @@ class TaskSchemaController extends AbstractController
|
||||
public function __construct(
|
||||
private TaskSchemaRepository $schemaRepository,
|
||||
private TaskSchemaManager $schemaManager,
|
||||
private TaskManager $taskManager,
|
||||
private TaskViewBuilder $taskViewBuilder,
|
||||
) {}
|
||||
|
||||
#[Route('', name: 'api_schemas_index', methods: ['GET'])]
|
||||
#[Route('', name: 'schemas.index', methods: ['GET'])]
|
||||
public function index(): JsonResponse
|
||||
{
|
||||
$schemas = $this->schemaRepository->findAll();
|
||||
@@ -33,7 +35,7 @@ class TaskSchemaController extends AbstractController
|
||||
return $this->json($schemas, context: ['groups' => ['schema:read', 'category:read']]);
|
||||
}
|
||||
|
||||
#[Route('/week', name: 'api_schemas_week', methods: ['GET'])]
|
||||
#[Route('/week', name: 'schemas.week', methods: ['GET'])]
|
||||
public function week(Request $request): JsonResponse
|
||||
{
|
||||
$startParam = $request->query->get('start');
|
||||
@@ -42,7 +44,7 @@ class TaskSchemaController extends AbstractController
|
||||
return $this->json($this->taskViewBuilder->buildWeekView($start));
|
||||
}
|
||||
|
||||
#[Route('/all', name: 'api_schemas_all', methods: ['GET'])]
|
||||
#[Route('/all', name: 'schemas.all', methods: ['GET'])]
|
||||
public function allSchemas(): JsonResponse
|
||||
{
|
||||
$schemas = $this->schemaRepository->findBy([], ['createdAt' => 'DESC']);
|
||||
@@ -50,19 +52,19 @@ class TaskSchemaController extends AbstractController
|
||||
return $this->json($schemas, context: ['groups' => ['schema:read', 'category:read']]);
|
||||
}
|
||||
|
||||
#[Route('/all-tasks', name: 'api_schemas_all_tasks', methods: ['GET'])]
|
||||
#[Route('/all-tasks', name: 'schemas.allTasks', methods: ['GET'])]
|
||||
public function allTasks(): JsonResponse
|
||||
{
|
||||
return $this->json($this->taskViewBuilder->buildAllTasksView());
|
||||
}
|
||||
|
||||
#[Route('/{id}', name: 'api_schemas_show', methods: ['GET'])]
|
||||
#[Route('/{id}', name: 'schemas.show', methods: ['GET'])]
|
||||
public function show(TaskSchema $schema): JsonResponse
|
||||
{
|
||||
return $this->json($schema, context: ['groups' => ['schema:read', 'category:read']]);
|
||||
}
|
||||
|
||||
#[Route('', name: 'api_schemas_create', methods: ['POST'])]
|
||||
#[Route('', name: 'schemas.create', methods: ['POST'])]
|
||||
public function create(#[MapRequestPayload] CreateSchemaRequest $dto): JsonResponse
|
||||
{
|
||||
$schema = $this->schemaManager->createSchema($dto);
|
||||
@@ -70,7 +72,7 @@ class TaskSchemaController extends AbstractController
|
||||
return $this->json($schema, Response::HTTP_CREATED, context: ['groups' => ['schema:read', 'category:read']]);
|
||||
}
|
||||
|
||||
#[Route('/{id}', name: 'api_schemas_update', methods: ['PUT'])]
|
||||
#[Route('/{id}', name: 'schemas.update', methods: ['PUT'])]
|
||||
public function update(#[MapRequestPayload] UpdateSchemaRequest $dto, TaskSchema $schema): JsonResponse
|
||||
{
|
||||
$schema = $this->schemaManager->updateSchema($schema, $dto);
|
||||
@@ -78,7 +80,7 @@ class TaskSchemaController extends AbstractController
|
||||
return $this->json($schema, context: ['groups' => ['schema:read', 'category:read']]);
|
||||
}
|
||||
|
||||
#[Route('/{id}', name: 'api_schemas_delete', methods: ['DELETE'])]
|
||||
#[Route('/{id}', name: 'schemas.delete', methods: ['DELETE'])]
|
||||
public function delete(TaskSchema $schema): JsonResponse
|
||||
{
|
||||
$this->schemaManager->deleteSchema($schema);
|
||||
@@ -86,10 +88,10 @@ class TaskSchemaController extends AbstractController
|
||||
return $this->json(null, Response::HTTP_NO_CONTENT);
|
||||
}
|
||||
|
||||
#[Route('/{id}/toggle', name: 'api_schemas_toggle', methods: ['PATCH'])]
|
||||
#[Route('/{id}/toggle', name: 'schemas.toggle', methods: ['PATCH'])]
|
||||
public function toggle(TaskSchema $schema, #[MapRequestPayload] ToggleRequest $dto): JsonResponse
|
||||
{
|
||||
$result = $this->schemaManager->toggleTaskStatus($schema, $dto);
|
||||
$result = $this->taskManager->toggleTaskStatus($schema, $dto);
|
||||
|
||||
return $this->json($result);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user