fix(composant) : persist piece/product/subcomponent selections on creation

The ComposantProcessor now reads the structure payload from the frontend
and applies selectedPieceId/selectedProductId/selectedComponentId to the
scaffolded slots, so user selections are actually saved to the database.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Matthieu
2026-03-23 12:04:19 +01:00
parent 826dae7712
commit 53b6abc9a8
2 changed files with 111 additions and 14 deletions

View File

@@ -131,6 +131,12 @@ class Composant
#[ORM\OrderBy(['position' => 'ASC'])]
private Collection $productSlots;
/**
* Transient — holds the structure payload sent by the frontend during creation.
* Not mapped to any column; consumed by ComposantProcessor.
*/
private ?array $pendingStructure = null;
#[ORM\Column(type: Types::INTEGER, options: ['default' => 1])]
#[Groups(['composant:read'])]
private int $version = 1;
@@ -395,6 +401,27 @@ class Composant
];
}
/**
* Called by API Platform during denormalization — stores the frontend
* structure payload so the ComposantProcessor can apply selections.
*/
public function setStructure(?array $structure): static
{
$this->pendingStructure = $structure;
return $this;
}
public function getPendingStructure(): ?array
{
return $this->pendingStructure;
}
public function clearPendingStructure(): void
{
$this->pendingStructure = null;
}
public function addProductSlot(ComposantProductSlot $productSlot): static
{
if (!$this->productSlots->contains($productSlot)) {