Commit d7d6493d authored by Mat's avatar Mat
Browse files

évite d'appeler 2x le même repository

parent 4ec5e852
......@@ -214,8 +214,7 @@ class LegumeAPIController extends MasterAPIController
public function insertAction(Request $request, $id)
{
$em = $this->getDoctrine()->getManager();
$legume = $em->getRepository('PotageBundle:Legume')->findOneForAPIRead($id);
// TODO temporaire, réutilise un repository déjà existant
$legume = $em->getRepository('PotageBundle:Legume')->findOneForAPIInsert($id);
if ($legume === null ) {
return $this->api($legume, Response::HTTP_NOT_FOUND);
......
......@@ -46,7 +46,20 @@ class LegumeRepository extends \Doctrine\ORM\EntityRepository
->setParameter(':id', $id);
return $qb->getQuery()->getOneOrNullResult();
}
/**
* @param $id
* @return mixed
* @throws \Doctrine\ORM\NonUniqueResultException
*/
public function findOneForAPIInsert($id)
{
$qb = $this->createQueryBuilder('l')
->where('l.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