Commit 684d7d4c authored by Mat's avatar Mat

ajoute la route readOne pour DepotAPI

parent 321c4bd8
......@@ -45,6 +45,23 @@ class DepotAPIController extends MasterAPIController
}
/**
* @param $id
* @return \Symfony\Component\HttpFoundation\JsonResponse
* @throws \Doctrine\ORM\NonUniqueResultException
*/
public function readOneAction($id)
{
$em = $this->getDoctrine()->getManager();
$depot = $em->getRepository('PotageBundle:Depot')->findOneForAPIReadOne($id);
if ($depot === null)
{
return $this->api('Not found', Response::HTTP_NOT_FOUND);
}
return $this->api($depot);
}
/**
* @param Request $request
* @param $id
......
......@@ -279,6 +279,14 @@ api_depot_read:
_controller: APIBundle:DepotAPI:read
methods: [ GET ]
api_depot_read_one:
path: /depot/{id}
requirements:
id: \d+
defaults:
_controller: APIBundle:DepotAPI:readOne
methods: [ GET ]
api_depot_update:
path: /depot/{id}
requirements:
......
......@@ -17,11 +17,25 @@ class DepotRepository extends \Doctrine\ORM\EntityRepository
public function findAllForAPIRead()
{
$qb = $this->createQueryBuilder('d')
->orderBy('d.nom, ASC');
->orderBy('d.nom', 'ASC');
return $qb->getQuery()->getResult();
}
/**
* @param $id
* @return mixed
* @throws \Doctrine\ORM\NonUniqueResultException
*/
public function findOneForAPIReadOne($id)
{
$qb = $this->createQueryBuilder('d')
->where('d.id = :id')
->setParameter(':id', $id);
return $qb->getQuery()->getOneOrNullResult();
}
/**
* @param $id
* @return mixed
......
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