composants->find($composantId); if (!$composant) { $this->mcpError('not_found', "Composant not found: {$composantId}"); } $constructeurs = []; foreach ($composant->getConstructeurs() as $c) { $constructeurs[] = [ 'id' => $c->getId(), 'name' => $c->getName(), ]; } $typeComposant = null; if ($composant->getTypeComposant()) { $typeComposant = [ 'id' => $composant->getTypeComposant()->getId(), 'name' => $composant->getTypeComposant()->getName(), ]; } return $this->jsonResponse([ 'id' => $composant->getId(), 'name' => $composant->getName(), 'reference' => $composant->getReference(), 'description' => $composant->getDescription(), 'prix' => $composant->getPrix(), 'typeComposant' => $typeComposant, 'constructeurs' => $constructeurs, 'createdAt' => $composant->getCreatedAt()->format('Y-m-d H:i:s'), 'updatedAt' => $composant->getUpdatedAt()->format('Y-m-d H:i:s'), ]); } }