Bonjour je suis un debutant desireux d'apprendre symfony avec l'architecture microservice bon presentement je suis confronte a un probleme lors de la serialisation de mes donnees avec API platform je n'arrive pas a serialiser mes resultats avec les groupes vraiment j'ai besoin de votre aide pour traverser cette etape de mon projet

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
 
<?php
 
namespace App\Entity;
 
use ApiPlatform\Core\Annotation\ApiResource;
use App\Repository\ProduitCmdRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
 
/**
 * @ApiResource(
 *     normalizationContext={"groups"={"read"}},
 *     denormalizationContext={"groups"={"write"}}
 * )
 * @ORM\Entity(repositoryClass=ProduitCmdRepository::class)
 */
class ProduitCmd
{
    /**
     * @ORM\Id
     * @ORM\GeneratedValue
     * @ORM\Column(type="integer")
     */
    private $id;
 
    /**
     * @ORM\ManyToOne(targetEntity=Produit::class, inversedBy="listCmd")
     * @ORM\JoinColumn(nullable=false)
     */
    private $idProd;
 
    /**
     * @ORM\Column(type="datetime")
     * @Groups({"read", "write"})
     */
    private $dateCmd;
 
    /**
     * @ORM\Column(type="integer")
     * @Groups({"read", "write"})
     */
    private $quantite;
 
    /**
     * @ORM\Column(type="integer")
     */
    private $prixU;
 
    /**
     * @ORM\ManyToOne(targetEntity=Employe::class, inversedBy="listCmd")
     * @ORM\JoinColumn(nullable=false)
     * @Groups({"read", "write"})
     */
    private $idEmpl;
 
    /**
     * @ORM\OneToOne(targetEntity=ProduitVal::class, mappedBy="id_cmd", cascade={"persist", "remove"})
     */
    private $validation;
 
    /**
     * @ORM\OneToOne(targetEntity=ProduitRej::class, mappedBy="idCmd", cascade={"persist", "remove"})
     */
    private $rejet;
 
    public function __construct()
    {
        $this->id_prod = new ArrayCollection();
    }
 
    public function getId(): ?int
    {
        return $this->id;
    }
 
    public function getIdProd(): ?Produit
    {
        return $this->idProd;
    }
 
    public function setIdProd(?Produit $idProd): self
    {
        $this->idProd = $idProd;
 
        return $this;
    }
 
    public function getDateCmd(): ?\DateTimeInterface
    {
        return $this->dateCmd;
    }
 
    public function setDateCmd(\DateTimeInterface $dateCmd): self
    {
        $this->dateCmd = $dateCmd;
 
        return $this;
    }
 
    public function getQuantite(): ?int
    {
        return $this->quantite;
    }
 
    public function setQuantite(int $quantite): self
    {
        $this->quantite = $quantite;
 
        return $this;
    }
 
    public function getPrixU(): ?int
    {
        return $this->prixU;
    }
 
    public function setPrixU(int $prixU): self
    {
        $this->prixU = $prixU;
 
        return $this;
    }
 
    public function getIdEmpl(): ?Employe
    {
        return $this->idEmpl;
    }
 
    public function setIdEmpl(?Employe $idEmpl): self
    {
        $this->idEmpl = $idEmpl;
 
        return $this;
    }
 
    public function getValidation(): ?ProduitVal
    {
        return $this->validation;
    }
 
    public function setValidation(ProduitVal $validation): self
    {
        $this->validation = $validation;
 
        // set the owning side of the relation if necessary
        if ($validation->getIdCmd() !== $this) {
            $validation->setIdCmd($this);
        }
 
        return $this;
    }
 
    public function getRejet(): ?ProduitRej
    {
        return $this->rejet;
    }
 
    public function setRejet(ProduitRej $rejet): self
    {
        $this->rejet = $rejet;
 
        // set the owning side of the relation if necessary
        if ($rejet->getIdCmd() !== $this) {
            $rejet->setIdCmd($this);
        }
 
        return $this;
    }
 
}
et voici le resultat

Nom : Capture.PNG
Affichages : 827
Taille : 51,4 Ko

les donnees des entites en relations avec l'entites courants ne s'affiche pas SVP aidez moi