は、私が使用しようknpPaginatorBundleとrest APIの使い方は?
パブリック関数listeleAction(リクエスト$リクエスト)$ { EM =の$ this - > getDoctrine() - > getManager();
$yasam_list=$em->getRepository("VanBundle:Yasam")->findAll();
if (count($yasam_list)>0)
{
$yanit=array();
foreach ($yasam_list as $meta)
{
$new_yasam=array();
$new_yasam['id']=$meta->getId();
$new_yasam['adi']=$meta->getAdi();
$new_yasam['adres']=$meta->getAdres();
$new_yasam['kategori_id']=$meta->getKategori()->getAdi();
array_push($yanit,$new_yasam);
}
$paginator=$this->get('knp_paginator');
$result= $paginator->paginate(
$yanit,
$request->query->getInt('page',1),
$request->query->getInt('limit',10)
);
}else{
$yanit["success"] = 0;
$response["message"] = "Bu kategoriye en kısa sürede veri eklenecektir. ";
}
$response=new Response(json_encode(array('yasamlar' =>$result),JSON_UNESCAPED_UNICODE));
$response->headers->set('Content-type','application/json; charset=utf-8');
$response->setStatusCode(200);
return $response;
}
私のJSON出力
{
"yasamlar": {}
}
どのように私はこの問題を解決することができますか?おかげで、すべての
を解決しましたか? –