Commit 710a3ac4 authored by Mat's avatar Mat
Browse files

Renommages dans le tri des OffreLegumes

parent db3936ba
......@@ -157,7 +157,7 @@ class OffreAPIController extends MasterAPIController
public function updateSortedAction(Request $request, $id)
{
$em = $this->getDoctrine()->getManager();
$offre = $em->getRepository('PotageBundle:Offre')->findOneForSorted($id);
$offre = $em->getRepository('PotageBundle:Offre')->findOneForSortedWhereStatus($id);
if ($offre === null)
{
......
......@@ -44,7 +44,10 @@ class OffreLegumesAPIController extends MasterAPIController
$em = $this->getDoctrine()->getManager();
// Récupère l'ordre de tri
$sorted = $em->getRepository('PotageBundle:Offre')->findOneForAPISorted($id_offre)->getSorted();
$sorted = $em->getRepository('PotageBundle:Offre')->findOneForSorted($id_offre)->getSorted();
// TODO tester qd $sorted est null
// est ce que c'est ce qui empeche de trier quand c'est pas draft ??
if (!empty($sorted))
{
......
......@@ -82,7 +82,7 @@ class OffreRepository extends \Doctrine\ORM\EntityRepository
* @return mixed
* @throws \Doctrine\ORM\NonUniqueResultException
*/
public function findOneForSorted($id)
public function findOneForDelete($id)
{
$qb = $this->createQueryBuilder('o')
->where('o.id = :id')
......@@ -99,44 +99,47 @@ class OffreRepository extends \Doctrine\ORM\EntityRepository
* @return mixed
* @throws \Doctrine\ORM\NonUniqueResultException
*/
public function findOneForDelete($id)
public function findOneForAPIRead($id)
{
$qb = $this->createQueryBuilder('o')
->select('o.id', 'o.createdAt', 'o.updatedAt', 'o.endedAt', 'o.status', 'o.reference')
->where('o.id = :id')
->andWhere('o.status = :status ')
->setParameters(array(
':id'=> $id,
':status' => 'draft'
));
->setParameter(':id', $id);
return $qb->getQuery()->getOneOrNullResult();
}
/**
* @param $id
* @return mixed
* @throws \Doctrine\ORM\NonUniqueResultException
*/
public function findOneForAPIRead($id)
public function findOneForSorted($id)
{
$qb = $this->createQueryBuilder('o')
->select('o.id', 'o.createdAt', 'o.updatedAt', 'o.endedAt', 'o.status', 'o.reference')
->where('o.id = :id')
->setParameter(':id', $id);
return $qb->getQuery()->getOneOrNullResult();
}
/**
* @param $id
* @return mixed
* @throws \Doctrine\ORM\NonUniqueResultException
*/
public function findOneForAPISorted($id)
public function findOneForSortedWhereStatus($id)
{
$qb = $this->createQueryBuilder('o')
->where('o.id = :id')
->setParameter(':id', $id);
->andWhere('o.status = :status ')
->setParameters(array(
':id'=> $id,
':status' => 'draft'
));
return $qb->getQuery()->getOneOrNullResult();
}
/**
* @param $id
......
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