feat(composant) : add composant slot entities for structure normalization

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Matthieu
2026-03-12 18:15:42 +01:00
parent 5336dfc09d
commit c01b71fe06
4 changed files with 450 additions and 0 deletions

View File

@@ -113,6 +113,27 @@ class Composant
#[ORM\OneToMany(mappedBy: 'composant', targetEntity: MachineComponentLink::class)]
private Collection $machineLinks;
/**
* @var Collection<int, ComposantPieceSlot>
*/
#[ORM\OneToMany(targetEntity: ComposantPieceSlot::class, mappedBy: 'composant', cascade: ['persist', 'remove'], orphanRemoval: true)]
#[ORM\OrderBy(['position' => 'ASC'])]
private Collection $pieceSlots;
/**
* @var Collection<int, ComposantSubcomponentSlot>
*/
#[ORM\OneToMany(targetEntity: ComposantSubcomponentSlot::class, mappedBy: 'composant', cascade: ['persist', 'remove'], orphanRemoval: true)]
#[ORM\OrderBy(['position' => 'ASC'])]
private Collection $subcomponentSlots;
/**
* @var Collection<int, ComposantProductSlot>
*/
#[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<int, ComposantPieceSlot>
*/
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<int, ComposantSubcomponentSlot>
*/
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<int, ComposantProductSlot>
*/
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;
}
}