Feat : update ads representation

This commit is contained in:
2018-09-06 09:48:12 +02:00
parent 9413202660
commit 870654c850
@@ -4,6 +4,7 @@ namespace AppBundle\Controller\Api;
use AppBundle\Entity\Ad;
use AppBundle\Representation\Ads;
use AppBundle\Representation\SingleAd;
use FOS\RestBundle\Controller\Annotations as Rest;
use FOS\RestBundle\Controller\Annotations\Get;
use FOS\RestBundle\Controller\Annotations\Post;
@@ -13,8 +14,6 @@ use FOS\RestBundle\Request\ParamFetcherInterface;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Hateoas\Configuration\Annotation as Hateoas;
use AppBundle\Representation\SingleAd;
class AdController extends FOSRestController
{
@@ -48,7 +47,7 @@ class AdController extends FOSRestController
* name="limit",
* requirements="\d+",
* default="15",
* description="Max number of movies per page."
* description="Max number of ads per page."
* )
* @Rest\QueryParam(
* name="offset",
@@ -80,7 +79,7 @@ class AdController extends FOSRestController
$em->persist($ad);
$em->flush();
return $this->view(
$ad,
new SingleAd($ad),
Response::HTTP_CREATED,
['Location' => $this->generateUrl('api_ad_show', ['id' => $ad->getId(), UrlGeneratorInterface::ABSOLUTE_URL])]);
}