<?php
namespace Aqarmap\Bundle\ListingBundle\Controller\Api\V4;
use Aqarmap\Bundle\ListingBundle\Entity\Section;
use Aqarmap\Bundle\ListingBundle\Repository\SectionRepository;
use Aqarmap\Bundle\MainBundle\Controller\Api\V4\BaseController;
use Doctrine\ORM\EntityManagerInterface;
use FOS\RestBundle\Controller\Annotations as Rest;
use FOS\RestBundle\View\View;
use Knp\Component\Pager\PaginatorInterface;
use Nelmio\ApiDocBundle\Annotation\Operation;
use OpenApi\Annotations as OA;
use Symfony\Component\HttpFoundation\Response;
class SectionController extends BaseController
{
/**
* @var EntityManagerInterface
*/
private $entityManager;
/**
* @var PaginatorInterface
*/
private $paginator;
public function __construct(EntityManagerInterface $entityManager, PaginatorInterface $paginator)
{
$this->entityManager = $entityManager;
$this->paginator = $paginator;
}
/**
* Section Search.
*
* @Operation(
* tags={"Section"},
* summary="Section Search.",
*
* @OA\Parameter(
* name="page",
* in="query",
* description="Page Number",
* required=false,
* ),
* @OA\Parameter(
* name="limit",
* in="query",
* description="Result Limit",
* required=false,
* ),
*
* @OA\Response(
* response="200",
* description="Returned when successfully created"
* )
* )
*
* @Rest\Get("/api/v4/sections", options={"i18n" = false}, name="aqarmap_api_section_search_v4")
*
* @Rest\QueryParam(name="page", description="Page Number")
* @Rest\QueryParam(name="limit", description="Result Limit")
*
* @Rest\View(serializerGroups={"DefaultV4"})
*
* @return View
*/
public function index()
{
/** @var SectionRepository $sectionRepository */
$sectionRepository = $this->entityManager->getRepository(Section::class);
$pagination = $this->paginator->paginate($sectionRepository->search(['isSearchable' => 1]));
return $this
->paginatedRespond(
$pagination,
Response::HTTP_OK
);
}
}