Commit d8486d42 authored by Mat's avatar Mat

wip.. en mode bourrin.. ça passe pas non plus grr

parent 45bb6564
......@@ -16,15 +16,26 @@ class OffreLegumesAPIController extends MasterAPIController
$em = $this->getDoctrine()->getManager();
$offre = $em->getRepository('PotageBundle:Offre')->findOneForAPIRead($id);
// TODO utilise actuellement le repository d'une autre action !
//$sorted = $offre->getSorted();
//if (count($sorted) > 0) {
// $legumes = $em->getRepository('PotageBundle:OffreLegumes')->findAllForSortedRead($id, $sorted);
$sorted = explode(',', $offre->getSorted());
if (count($offre->getSorted()) > 0)
{
$sorted = $offre->getSorted();
$legumes = $em->getRepository('PotageBundle:OffreLegumes')->findAllForSortedRead($id, $sorted);
$legume = array();
foreach ($sorted as $item)
{
$legume[] = $em->getRepository('PotageBundle:OffreLegumes')->findOneForSortedRead($item);
}
$legumes = $legume;
}
else {
$legumes = $em->getRepository('PotageBundle:OffreLegumes')->findAllForRead($id);
}
dump($legumes);
return $this->api($legumes);
}
}
......@@ -328,13 +328,13 @@ class Offre
/**
* Set sorted
*
* @param mixed $sorted
* @param mixed $sorted_in
*
* @return Offre
*/
public function setSorted($sorted)
public function setSorted($sorted_in)
{
is_array($sorted) ? $sorted = explode(",", $sorted) : null;
$sorted = is_array($sorted) ? $sorted_in : explode(",", $sorted_in);
$this->sorted = $sorted;
return $this;
......
......@@ -68,7 +68,6 @@ class OffreLegumesRepository extends \Doctrine\ORM\EntityRepository
* @param $id_offre = '22'
* @param $sorted = '20,26,22,27,45,46'
*
*/
//1
$qb = $this->createQueryBuilder('ol')
......@@ -87,6 +86,7 @@ class OffreLegumesRepository extends \Doctrine\ORM\EntityRepository
))
;
return $qb->getQuery()->getResult();
*/
/*
//2
......@@ -103,5 +103,21 @@ class OffreLegumesRepository extends \Doctrine\ORM\EntityRepository
))
->getResult();
*/
return null;
}
/**
* @param $id_offre
* @param $id
* @return mixed
* @throws \Doctrine\ORM\NonUniqueResultException
*/
public function findOneForSortedRead($id)
{
return $this->createQueryBuilder('ol')
->where('ol.id = :id')
->setParameter(':id', $id)
->getQuery()
->getOneOrNullResult();
}
}
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