bonjour tout le monde,
j'aurais une question pour les pro symfonyrest en fait j'ai un soucis avec JMSSerializer , mon soucis est que j'arrive pas a récupérer mon Discriminator dans un group ,(pour les exclusion) j'ai une classe user qui extends Customer + Coach (différents types d'utilisateurs) et j'ai besoin justement de l'attribut "type" pour mon app
classe user :
<?php
/**
* User
* @ORM\Entity(repositoryClass="UserBundle\Repository\UserRepository")
* @ORM\Table(name="user")
* @ORM\InheritanceType("JOINED")
* @ORM\DiscriminatorColumn(name="type", type="string")
* @ORM\DiscriminatorMap({"Customer" = "Customer", "Company" = "Company", "Coach" = "Coach"})
* @JMS\Discriminator(field="type", map={"Customer": "UserBundle\Entity\Customer", "Coach": "UserBundle\Entity\Coach"}, groups = {"DefaultUser"})<br> * @JMS\ExclusionPolicy("all")
*/
abstract class User extends BaseUser
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
* @JMS\Groups({"DefaultUser"})
*
*/
protected $id;
ma classe customer
<?php
namespace UserBundle\Entity;
use UserBundle\Entity\User as User;
use Doctrine\ORM\Mapping as ORM;
use PUGX\MultiUserBundle\Validator\Constraints\UniqueEntity;
use JMS\Serializer\Annotation\ExclusionPolicy;
use JMS\Serializer\Annotation\Expose;
use JMS\Serializer\Annotation as JMS;
/**
* Customer
* @ORM\Entity
* @ORM\Table(name="customer")
* @UniqueEntity(fields = "username", targetClass = "UserBundle\Entity\User", message="fos_user.username.already_used")
* @UniqueEntity(fields = "email", targetClass = "UserBundle\Entity\User", message="fos_user.email.already_used")
* @ExclusionPolicy("all")
*
*/
class Customer extends User
{
/**
* @var int
*
* @Expose
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
* @JMS\Groups({"DefaultUser"})
*/
protected $id;
class coach
<?php
namespace UserBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use UserBundle\Entity\User as User;
use PUGX\MultiUserBundle\Validator\Constraints\UniqueEntity;
use JMS\Serializer\Annotation\ExclusionPolicy;
use JMS\Serializer\Annotation\Expose;
use JMS\Serializer\Annotation\Groups;
use JMS\Serializer\Annotation\VirtualProperty;
use JMS\Serializer\Annotation as JMS;
/**
* Coach
* @ORM\Entity
* @ORM\Table(name="coach")
* @UniqueEntity(fields = "username", targetClass = "UserBundle\Entity\User", message="fos_user.username.already_used")
* @UniqueEntity(fields = "email", targetClass = "UserBundle\Entity\User", message="fos_user.email.already_used")
*
*/
class Coach extends User
{
/**
* @var int
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @Expose
* @ORM\GeneratedValue(strategy="AUTO")
* @JMS\Groups({"DefaultUser"})
*/
protected $id;