<?php
namespace App\Controller\Api;
use App\Entity\Catalogos\{EntidadFinanciera, MedioPago, Seccion};
use App\Service\CatalogosManager;
use Doctrine\ORM\EntityManagerInterface;
use FOS\RestBundle\Controller\AbstractFOSRestController;
use FOS\RestBundle\Controller\Annotations as Rest;
use Symfony\Component\HttpFoundation\{Request, Response};
class CatalogosController extends AbstractFOSRestController {
/**
* @Rest\Get(path="/api/v2/generales/catalogos/getProvincias")
* @Rest\View(serializerGroups={"provincias"}, serializerEnableMaxDepthChecks=true)
*/
public function getProvincias(CatalogosManager $catalogosManager) {
$data = $catalogosManager->getProvincias();
return $this->json(['response' => true, 'results' => $data]);
}
/**
* @Rest\Get(path="/api/v2/generales/catalogos/getCantones/{idProvincia}",requirements={"idProvincia"="\d+"})
* @Rest\View(serializerGroups={"cantones"}, serializerEnableMaxDepthChecks=true)
*/
public function getCantones(
int $idProvincia,
CatalogosManager $catalogosManager
) {
$data = $catalogosManager->getCantonesInProvincia($idProvincia);
return $this->json(['response' => true, 'results' => $data]);
}
/**
* @Rest\Get(path="/api/v2/generales/catalogos/getParroquias/{idCanton}",requirements={"idCanton"="\d+"})
* @Rest\View(serializerGroups={"parroquias"}, serializerEnableMaxDepthChecks=true)
*/
public function getParroquias(
int $idCanton,
CatalogosManager $catalogosManager
) {
$data = $catalogosManager->getParroquiasInCanton($idCanton);
return $this->json(['response' => true, 'results' => $data]);
}
/**
* @Rest\Get(path="/api/v2/generales/catalogos/getCategorias")
* @Rest\View(serializerGroups={"categorias", "document"}, serializerEnableMaxDepthChecks=true)
*/
public function getCategoriasProductos(
CatalogosManager $catalogosManager
) {
$data = $catalogosManager->getCategoriasProductos();
return $this->json(['response' => true, 'results' => $data]);
}
/**
* @Rest\Get(path="/api/v2/generales/catalogos/getCupones")
* @Rest\View(serializerGroups={"categorias", "document"}, serializerEnableMaxDepthChecks=true)
*/
public function getCupones(
CatalogosManager $catalogosManager
) {
$data = $catalogosManager->getCupones();
return $this->json(['response' => true, 'results' => $data]);
}
/**
* @Rest\Get(path="/api/v2/generales/catalogos/getMediosPago")
* @Rest\View(serializerGroups={"medioPago"}, serializerEnableMaxDepthChecks=true)
*/
public function getMediosPago(
EntityManagerInterface $em
) {
$data = $em->getRepository(MedioPago::class)->findAll();
return $this->json(['response' => true, 'results' => $data]);
}
/**
* @Rest\Get(path="/api/v2/generales/catalogos/getSeccion")
*/
public function getSeccion(
EntityManagerInterface $em
) {
$data = $em->getRepository(Seccion::class)->findAll();
return $this->json(['response' => true, 'results' => $data]);
}
/**
* @Rest\Get(path="/api/v2/generales/catalogos/getEntidadFinanciera")
*/
public function getEntidadFinanciera(
EntityManagerInterface $em
) {
$data = $em->getRepository(EntidadFinanciera::class)->findAll();
return $this->json(['response' => true, 'results' => $data]);
}
}