Commit a327bfe3 authored by Mat's avatar Mat
Browse files

readAction pour les 2 entités Info et Lettre

parent b2dd199c
......@@ -2,7 +2,39 @@
namespace APIBundle\Controller;
use Symfony\Component\HttpFoundation\Request;
class InfoAPIController extends MasterAPIController
{
public function createAction(Request $request)
{
}
/**
* @return \Symfony\Component\HttpFoundation\JsonResponse
*/
public function readAction()
{
$em = $this->getDoctrine()->getManager();
$infos = $em->getRepository('PotageBundle:Info')->findAllForAPIRead();
return $this->api($infos);
}
public function readOneAction($id)
{
}
public function updateAction(Request $request, $id)
{
}
public function deleteAction($id)
{
}
}
......@@ -2,6 +2,39 @@
namespace APIBundle\Controller;
use Symfony\Component\HttpFoundation\Request;
class LettreAPIController extends MasterAPIController
{
public function createAction(Request $request)
{
}
/**
* @return \Symfony\Component\HttpFoundation\JsonResponse
*/
public function readAction()
{
$em = $this->getDoctrine()->getManager();
$lettres = $em->getRepository('PotageBundle:Lettre')->findAllForAPIRead();
return $this->api($lettres);
}
public function readOneAction($id)
{
}
public function updateAction(Request $request, $id)
{
}
public function deleteAction($id)
{
}
}
......@@ -114,3 +114,20 @@ api_offre_legumes_read:
defaults:
_controller: APIBundle:OffreLegumesAPI:read
methods: [ GET ]
## CRUD LettreAPI
api_lettre_read:
path: /lettres
defaults:
_controller: APIBundle:LettreAPI:read
methods: [ GET ]
## CRUD InfoAPI
api_info_read:
path: /infos
defaults:
_controller: APIBundle:InfoAPI:read
methods: [ GET ]
......@@ -10,4 +10,16 @@ namespace PotageBundle\Repository;
*/
class InfoRepository extends \Doctrine\ORM\EntityRepository
{
/**
* @return array Info
*/
public function findAllForAPIRead()
{
$qb = $this->createQueryBuilder('i')
->orderBy('i.id', 'DESC');
return $qb->getQuery()->getResult();
}
}
......@@ -10,4 +10,14 @@ namespace PotageBundle\Repository;
*/
class LettreRepository extends \Doctrine\ORM\EntityRepository
{
/**
* @return array Lettre
*/
public function findAllForAPIRead()
{
$qb = $this->createQueryBuilder('l')
->orderBy('l.id', 'DESC');
return $qb->getQuery()->getResult();
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment