feat(structure) : read composant structure from slot relations instead of JSON

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Matthieu
2026-03-12 18:23:56 +01:00
parent 5194543d16
commit 8ed5f90b63
2 changed files with 48 additions and 48 deletions

View File

@@ -212,9 +212,13 @@ class Piece
{
$this->product = $product;
if ($product && empty($this->productIds)) {
$productId = $product->getId();
$this->productIds = $productId ? [$productId] : null;
if (null !== $product) {
$this->addProduct($product);
if (empty($this->productIds)) {
$productId = $product->getId();
$this->productIds = $productId ? [$productId] : null;
}
}
if (!$product && empty($this->productIds)) {
@@ -229,19 +233,7 @@ class Piece
*/
public function getProductIds(): array
{
if (!is_array($this->productIds)) {
return [];
}
return array_values(
array_filter(
array_map(
static fn ($value) => is_string($value) ? trim($value) : '',
$this->productIds,
),
static fn (string $value) => '' !== $value,
),
);
return $this->products->map(fn (Product $p) => $p->getId())->toArray();
}
public function setProductIds(?array $productIds): static