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 @@ ...@@ -2,8 +2,8 @@
namespace Api2Bundle\Entity; namespace Api2Bundle\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use JMS\Serializer\Annotation as Serializer;
/** /**
* Brasserie * Brasserie
...@@ -19,6 +19,7 @@ class Brasserie ...@@ -19,6 +19,7 @@ class Brasserie
* @ORM\Column(name="id", type="integer") * @ORM\Column(name="id", type="integer")
* @ORM\Id * @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO") * @ORM\GeneratedValue(strategy="AUTO")
* @Serializer\Groups({"getBrasserie"})
*/ */
private $id; private $id;
...@@ -26,20 +27,21 @@ class Brasserie ...@@ -26,20 +27,21 @@ class Brasserie
* @var integer * @var integer
* @ORM\ManyToOne(targetEntity="Api2Bundle\Entity\Pays") * @ORM\ManyToOne(targetEntity="Api2Bundle\Entity\Pays")
* @ORM\JoinColumn(name="id_pays", nullable=false) * @ORM\JoinColumn(name="id_pays", nullable=false)
* @Serializer\Groups({"getBrasserie"})
*/ */
private $pays; private $pays;
/** /**
* @var string * @var string
*
* @ORM\Column(name="nom", type="string", length=255) * @ORM\Column(name="nom", type="string", length=255)
* @Serializer\Groups({"getBrasserie"})
*/ */
private $nom; private $nom;
/** /**
* @var string * @var string
*
* @ORM\Column(name="adresse", type="string", length=255, nullable=true) * @ORM\Column(name="adresse", type="string", length=255, nullable=true)
* @Serializer\Groups({"getBrasserie"})
*/ */
private $adresse; private $adresse;
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
namespace Api2Bundle\Entity; namespace Api2Bundle\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
/** /**
* Categorie * Categorie
* *
......
...@@ -2,8 +2,9 @@ ...@@ -2,8 +2,9 @@
namespace Api2Bundle\Entity; namespace Api2Bundle\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use JMS\Serializer\Annotation as Serializer;
/** /**
* Pays * Pays
...@@ -19,6 +20,7 @@ class Pays ...@@ -19,6 +20,7 @@ class Pays
* @ORM\Column(name="id", type="integer") * @ORM\Column(name="id", type="integer")
* @ORM\Id * @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO") * @ORM\GeneratedValue(strategy="AUTO")
* @Serializer\Groups({"getBrasserie"})
*/ */
private $id; private $id;
...@@ -33,6 +35,7 @@ class Pays ...@@ -33,6 +35,7 @@ class Pays
* @var string * @var string
* *
* @ORM\Column(name="nom", type="string", length=255) * @ORM\Column(name="nom", type="string", length=255)
* @Serializer\Groups({"getBrasserie"})
*/ */
private $nom; 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