From c01b71fe06f8898024123b94a9a9f47ecc719b70 Mon Sep 17 00:00:00 2001 From: Matthieu Date: Thu, 12 Mar 2026 18:15:42 +0100 Subject: [PATCH] feat(composant) : add composant slot entities for structure normalization Co-Authored-By: Claude Opus 4.6 --- src/Entity/Composant.php | 99 ++++++++++++++++++ src/Entity/ComposantPieceSlot.php | 112 ++++++++++++++++++++ src/Entity/ComposantProductSlot.php | 112 ++++++++++++++++++++ src/Entity/ComposantSubcomponentSlot.php | 127 +++++++++++++++++++++++ 4 files changed, 450 insertions(+) create mode 100644 src/Entity/ComposantPieceSlot.php create mode 100644 src/Entity/ComposantProductSlot.php create mode 100644 src/Entity/ComposantSubcomponentSlot.php diff --git a/src/Entity/Composant.php b/src/Entity/Composant.php index d7033e2..a7b0cf9 100644 --- a/src/Entity/Composant.php +++ b/src/Entity/Composant.php @@ -113,6 +113,27 @@ class Composant #[ORM\OneToMany(mappedBy: 'composant', targetEntity: MachineComponentLink::class)] private Collection $machineLinks; + /** + * @var Collection + */ + #[ORM\OneToMany(targetEntity: ComposantPieceSlot::class, mappedBy: 'composant', cascade: ['persist', 'remove'], orphanRemoval: true)] + #[ORM\OrderBy(['position' => 'ASC'])] + private Collection $pieceSlots; + + /** + * @var Collection + */ + #[ORM\OneToMany(targetEntity: ComposantSubcomponentSlot::class, mappedBy: 'composant', cascade: ['persist', 'remove'], orphanRemoval: true)] + #[ORM\OrderBy(['position' => 'ASC'])] + private Collection $subcomponentSlots; + + /** + * @var Collection + */ + #[ORM\OneToMany(targetEntity: ComposantProductSlot::class, mappedBy: 'composant', cascade: ['persist', 'remove'], orphanRemoval: true)] + #[ORM\OrderBy(['position' => 'ASC'])] + private Collection $productSlots; + #[ORM\Column(type: Types::DATETIME_IMMUTABLE, name: 'createdAt')] #[Groups(['composant:read'])] private DateTimeImmutable $createdAt; @@ -129,6 +150,9 @@ class Composant $this->documents = new ArrayCollection(); $this->customFieldValues = new ArrayCollection(); $this->machineLinks = new ArrayCollection(); + $this->pieceSlots = new ArrayCollection(); + $this->subcomponentSlots = new ArrayCollection(); + $this->productSlots = new ArrayCollection(); } public function getName(): string @@ -270,4 +294,79 @@ class Composant { return $this->customFieldValues; } + + /** + * @return Collection + */ + public function getPieceSlots(): Collection + { + return $this->pieceSlots; + } + + public function addPieceSlot(ComposantPieceSlot $pieceSlot): static + { + if (!$this->pieceSlots->contains($pieceSlot)) { + $this->pieceSlots->add($pieceSlot); + $pieceSlot->setComposant($this); + } + + return $this; + } + + public function removePieceSlot(ComposantPieceSlot $pieceSlot): static + { + $this->pieceSlots->removeElement($pieceSlot); + + return $this; + } + + /** + * @return Collection + */ + public function getSubcomponentSlots(): Collection + { + return $this->subcomponentSlots; + } + + public function addSubcomponentSlot(ComposantSubcomponentSlot $subcomponentSlot): static + { + if (!$this->subcomponentSlots->contains($subcomponentSlot)) { + $this->subcomponentSlots->add($subcomponentSlot); + $subcomponentSlot->setComposant($this); + } + + return $this; + } + + public function removeSubcomponentSlot(ComposantSubcomponentSlot $subcomponentSlot): static + { + $this->subcomponentSlots->removeElement($subcomponentSlot); + + return $this; + } + + /** + * @return Collection + */ + public function getProductSlots(): Collection + { + return $this->productSlots; + } + + public function addProductSlot(ComposantProductSlot $productSlot): static + { + if (!$this->productSlots->contains($productSlot)) { + $this->productSlots->add($productSlot); + $productSlot->setComposant($this); + } + + return $this; + } + + public function removeProductSlot(ComposantProductSlot $productSlot): static + { + $this->productSlots->removeElement($productSlot); + + return $this; + } } diff --git a/src/Entity/ComposantPieceSlot.php b/src/Entity/ComposantPieceSlot.php new file mode 100644 index 0000000..3d3f303 --- /dev/null +++ b/src/Entity/ComposantPieceSlot.php @@ -0,0 +1,112 @@ + 1])] + private int $quantity = 1; + + #[ORM\Column(type: Types::INTEGER, options: ['default' => 0])] + private int $position = 0; + + #[ORM\Column(type: Types::DATETIME_IMMUTABLE, name: 'createdAt')] + private DateTimeImmutable $createdAt; + + #[ORM\Column(type: Types::DATETIME_IMMUTABLE, name: 'updatedAt')] + private DateTimeImmutable $updatedAt; + + public function __construct() + { + $this->createdAt = new DateTimeImmutable(); + $this->updatedAt = new DateTimeImmutable(); + } + + public function getComposant(): Composant + { + return $this->composant; + } + + public function setComposant(Composant $composant): static + { + $this->composant = $composant; + + return $this; + } + + public function getTypePiece(): ?ModelType + { + return $this->typePiece; + } + + public function setTypePiece(?ModelType $typePiece): static + { + $this->typePiece = $typePiece; + + return $this; + } + + public function getSelectedPiece(): ?Piece + { + return $this->selectedPiece; + } + + public function setSelectedPiece(?Piece $selectedPiece): static + { + $this->selectedPiece = $selectedPiece; + + return $this; + } + + public function getQuantity(): int + { + return $this->quantity; + } + + public function setQuantity(int $quantity): static + { + $this->quantity = $quantity; + + return $this; + } + + public function getPosition(): int + { + return $this->position; + } + + public function setPosition(int $position): static + { + $this->position = $position; + + return $this; + } +} diff --git a/src/Entity/ComposantProductSlot.php b/src/Entity/ComposantProductSlot.php new file mode 100644 index 0000000..9872c7e --- /dev/null +++ b/src/Entity/ComposantProductSlot.php @@ -0,0 +1,112 @@ + 0])] + private int $position = 0; + + #[ORM\Column(type: Types::DATETIME_IMMUTABLE, name: 'createdAt')] + private DateTimeImmutable $createdAt; + + #[ORM\Column(type: Types::DATETIME_IMMUTABLE, name: 'updatedAt')] + private DateTimeImmutable $updatedAt; + + public function __construct() + { + $this->createdAt = new DateTimeImmutable(); + $this->updatedAt = new DateTimeImmutable(); + } + + public function getComposant(): Composant + { + return $this->composant; + } + + public function setComposant(Composant $composant): static + { + $this->composant = $composant; + + return $this; + } + + public function getTypeProduct(): ?ModelType + { + return $this->typeProduct; + } + + public function setTypeProduct(?ModelType $typeProduct): static + { + $this->typeProduct = $typeProduct; + + return $this; + } + + public function getSelectedProduct(): ?Product + { + return $this->selectedProduct; + } + + public function setSelectedProduct(?Product $selectedProduct): static + { + $this->selectedProduct = $selectedProduct; + + return $this; + } + + public function getFamilyCode(): ?string + { + return $this->familyCode; + } + + public function setFamilyCode(?string $familyCode): static + { + $this->familyCode = $familyCode; + + return $this; + } + + public function getPosition(): int + { + return $this->position; + } + + public function setPosition(int $position): static + { + $this->position = $position; + + return $this; + } +} diff --git a/src/Entity/ComposantSubcomponentSlot.php b/src/Entity/ComposantSubcomponentSlot.php new file mode 100644 index 0000000..779655e --- /dev/null +++ b/src/Entity/ComposantSubcomponentSlot.php @@ -0,0 +1,127 @@ + 0])] + private int $position = 0; + + #[ORM\Column(type: Types::DATETIME_IMMUTABLE, name: 'createdAt')] + private DateTimeImmutable $createdAt; + + #[ORM\Column(type: Types::DATETIME_IMMUTABLE, name: 'updatedAt')] + private DateTimeImmutable $updatedAt; + + public function __construct() + { + $this->createdAt = new DateTimeImmutable(); + $this->updatedAt = new DateTimeImmutable(); + } + + public function getComposant(): Composant + { + return $this->composant; + } + + public function setComposant(Composant $composant): static + { + $this->composant = $composant; + + return $this; + } + + public function getAlias(): ?string + { + return $this->alias; + } + + public function setAlias(?string $alias): static + { + $this->alias = $alias; + + return $this; + } + + public function getFamilyCode(): ?string + { + return $this->familyCode; + } + + public function setFamilyCode(?string $familyCode): static + { + $this->familyCode = $familyCode; + + return $this; + } + + public function getTypeComposant(): ?ModelType + { + return $this->typeComposant; + } + + public function setTypeComposant(?ModelType $typeComposant): static + { + $this->typeComposant = $typeComposant; + + return $this; + } + + public function getSelectedComposant(): ?Composant + { + return $this->selectedComposant; + } + + public function setSelectedComposant(?Composant $selectedComposant): static + { + $this->selectedComposant = $selectedComposant; + + return $this; + } + + public function getPosition(): int + { + return $this->position; + } + + public function setPosition(int $position): static + { + $this->position = $position; + + return $this; + } +}