feat(machine) : exposer structure composant + pièces résolues dans la vue machine

- normalizeComposant : inclure structure du composant dans la réponse
- enrichStructureWithPieceData : résoudre selectedPieceId vers les
  données complètes de la pièce catalogue (nom, référence, prix, etc.)
- Update submodule : affichage pièces incluses + quantité machine

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Matthieu
2026-03-12 17:23:55 +01:00
parent eccbc1bd56
commit 333f2a88af
2 changed files with 24 additions and 1 deletions

View File

@@ -709,6 +709,7 @@ class MachineStructureController extends AbstractController
'typeComposant' => $this->normalizeModelType($type),
'productId' => $composant->getProduct()?->getId(),
'product' => $composant->getProduct() ? $this->normalizeProduct($composant->getProduct()) : null,
'structure' => $this->enrichStructureWithPieceData($composant->getStructure()),
'constructeurs' => $this->normalizeConstructeurs($composant->getConstructeurs()),
'documents' => [],
'customFields' => $type ? $this->normalizeCustomFieldDefinitions($type->getComponentCustomFields()) : [],
@@ -716,6 +717,28 @@ class MachineStructureController extends AbstractController
];
}
private function enrichStructureWithPieceData(?array $structure): ?array
{
if (!is_array($structure) || !isset($structure['pieces']) || !is_array($structure['pieces'])) {
return $structure;
}
foreach ($structure['pieces'] as &$entry) {
if (!is_array($entry)) {
continue;
}
$selectedId = $entry['selectedPieceId'] ?? null;
if ($selectedId) {
$piece = $this->pieceRepository->find($selectedId);
if ($piece instanceof Piece) {
$entry['resolvedPiece'] = $this->normalizePiece($piece);
}
}
}
return $structure;
}
private function normalizePiece(Piece $piece): array
{
$type = $piece->getTypePiece();