Commit e8defcd0 authored by Mat's avatar Mat

groupe de serialisation pour la route get de Brasserie

parent 7281cc24
<?php
namespace Api2Bundle\Controller;
use Api2Bundle\Entity\Brasserie;
use FOS\RestBundle\Controller\Annotations as Rest;
use FOS\RestBundle\Controller\FOSRestController;
class BrasserieController extends FOSRestController
{
/**
* @Rest\Get(path="/brasserie")
* @Rest\View(serializerGroups={"getBrasserie"})
*/
public function getAction()
{
return $this->getDoctrine()
->getRepository(Brasserie::class)
->findAll();
}
}
......@@ -2,8 +2,8 @@
namespace Api2Bundle\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use JMS\Serializer\Annotation as Serializer;
/**
* Brasserie
......@@ -19,6 +19,7 @@ class Brasserie
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
* @Serializer\Groups({"getBrasserie"})
*/
private $id;
......@@ -26,20 +27,21 @@ class Brasserie
* @var integer
* @ORM\ManyToOne(targetEntity="Api2Bundle\Entity\Pays")
* @ORM\JoinColumn(name="id_pays", nullable=false)
* @Serializer\Groups({"getBrasserie"})
*/
private $pays;
/**
* @var string
*
* @ORM\Column(name="nom", type="string", length=255)
* @Serializer\Groups({"getBrasserie"})
*/
private $nom;
/**
* @var string
*
* @ORM\Column(name="adresse", type="string", length=255, nullable=true)
* @Serializer\Groups({"getBrasserie"})
*/
private $adresse;
......
......@@ -2,9 +2,9 @@
namespace Api2Bundle\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
/**
* Categorie
*
......
......@@ -2,8 +2,9 @@
namespace Api2Bundle\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use JMS\Serializer\Annotation as Serializer;
/**
* Pays
......@@ -19,6 +20,7 @@ class Pays
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
* @Serializer\Groups({"getBrasserie"})
*/
private $id;
......@@ -33,6 +35,7 @@ class Pays
* @var string
*
* @ORM\Column(name="nom", type="string", length=255)
* @Serializer\Groups({"getBrasserie"})
*/
private $nom;
......
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