Commit 617fae1b authored by Mat's avatar Mat

owner readone, retourne un seul owner

parent 6851ef86
......@@ -19,6 +19,19 @@ class OwnerController extends MasterAPIController
}
/**
* @return \Symfony\Component\HttpFoundation\JsonResponse
*/
public function readOneAction($id)
{
$em = $this->getDoctrine()->getManager();
$owner = $em->getRepository('TechnoBundle:Owner')
->findOneForAPIRead($id);
return $this->api($owner);
}
/*
$serializer = $this->get('jms_serializer');
$serialized = $serializer->serialize($data, 'json');
......
......@@ -3,3 +3,11 @@ api_owner_read:
defaults:
_controller: APIBundle:Owner:read
methods: [ GET ]
api_owner_read_one:
path: /owner/{id}
requirements:
id: \d+
defaults:
_controller: APIBundle:Owner:readOne
methods: [ GET ]
......@@ -59,5 +59,18 @@ class OwnerRepository extends \Doctrine\ORM\EntityRepository
return $qb->getQuery()->getResult();
}
/**
* @param $id
* @return Owner
* @throws \Doctrine\ORM\NonUniqueResultException
*/
public function findOneForAPIRead($id)
{
$qb = $this->createQueryBuilder('o')
->where('o.id = :id')
->setParameter(':id', $id);
return $qb->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