src/Aqarmap/Bundle/ListingBundle/Controller/Api/V4/SectionController.php line 68

Open in your IDE?
  1. <?php
  2. namespace Aqarmap\Bundle\ListingBundle\Controller\Api\V4;
  3. use Aqarmap\Bundle\ListingBundle\Entity\Section;
  4. use Aqarmap\Bundle\ListingBundle\Repository\SectionRepository;
  5. use Aqarmap\Bundle\MainBundle\Controller\Api\V4\BaseController;
  6. use Doctrine\ORM\EntityManagerInterface;
  7. use FOS\RestBundle\Controller\Annotations as Rest;
  8. use FOS\RestBundle\View\View;
  9. use Knp\Component\Pager\PaginatorInterface;
  10. use Nelmio\ApiDocBundle\Annotation\Operation;
  11. use OpenApi\Annotations as OA;
  12. use Symfony\Component\HttpFoundation\Response;
  13. class SectionController extends BaseController
  14. {
  15.     /**
  16.      * @var EntityManagerInterface
  17.      */
  18.     private $entityManager;
  19.     /**
  20.      * @var PaginatorInterface
  21.      */
  22.     private $paginator;
  23.     public function __construct(EntityManagerInterface $entityManagerPaginatorInterface $paginator)
  24.     {
  25.         $this->entityManager $entityManager;
  26.         $this->paginator $paginator;
  27.     }
  28.     /**
  29.      * Section Search.
  30.      *
  31.      * @Operation(
  32.      *     tags={"Section"},
  33.      *     summary="Section Search.",
  34.      *
  35.      *     @OA\Parameter(
  36.      *         name="page",
  37.      *         in="query",
  38.      *         description="Page Number",
  39.      *         required=false,
  40.      *     ),
  41.      *     @OA\Parameter(
  42.      *         name="limit",
  43.      *         in="query",
  44.      *         description="Result Limit",
  45.      *         required=false,
  46.      *     ),
  47.      *
  48.      *     @OA\Response(
  49.      *         response="200",
  50.      *         description="Returned when successfully created"
  51.      *     )
  52.      * )
  53.      *
  54.      * @Rest\Get("/api/v4/sections", options={"i18n" = false}, name="aqarmap_api_section_search_v4")
  55.      *
  56.      * @Rest\QueryParam(name="page", description="Page Number")
  57.      * @Rest\QueryParam(name="limit", description="Result Limit")
  58.      *
  59.      * @Rest\View(serializerGroups={"DefaultV4"})
  60.      *
  61.      * @return View
  62.      */
  63.     public function index()
  64.     {
  65.         /** @var SectionRepository $sectionRepository */
  66.         $sectionRepository $this->entityManager->getRepository(Section::class);
  67.         $pagination $this->paginator->paginate($sectionRepository->search(['isSearchable' => 1]));
  68.         return $this
  69.             ->paginatedRespond(
  70.                 $pagination,
  71.                 Response::HTTP_OK
  72.             );
  73.     }
  74. }