diff --git a/api/src/Controller/IndexController.php b/api/src/Controller/IndexController.php index 8ed2b3a..c998164 100644 --- a/api/src/Controller/IndexController.php +++ b/api/src/Controller/IndexController.php @@ -2,6 +2,7 @@ namespace App\Controller; +use App\Pagination\Paginator; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; @@ -13,8 +14,8 @@ final class IndexController extends AbstractController #[Route('/', name: 'fruits', methods: ['GET'])] public function all(Request $request, FruitRepository $fruits): JsonResponse { - $page = (int) $request->get('page'); - $size = (int) $request->get('size'); + $page = (int) $request->get('page', 1); + $size = (int) $request->get('size', Paginator::PAGE_SIZE) ?: Paginator::PAGE_SIZE; $orderBy = $request->get('order_by', 'name'); $search = $request->get('search'); $direction = $request->get('direction', 'ASC'); diff --git a/api/tests/Controller/IndexControllTest.php b/api/tests/Controller/IndexControllTest.php index 876fa25..4537c62 100644 --- a/api/tests/Controller/IndexControllTest.php +++ b/api/tests/Controller/IndexControllTest.php @@ -22,6 +22,5 @@ public function testAll() $this->assertArrayHasKey('pageSize', $data); $this->assertArrayHasKey('results', $data); $this->assertArrayHasKey('numResults', $data); - } }