feat(reference-auto) : add automatic reference generation for pieces
ModelType defines a formula with placeholders ({serie}{diametre}{type}).
ReferenceAutoGenerator resolves it from CustomFieldValues with trim+uppercase normalisation.
ReferenceAutoSubscriber (onFlush) recalculates on Piece/CFV insert/update/delete.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -73,6 +73,14 @@ class ModelType
|
||||
#[Groups(['type_machine:read', 'model_type:read', 'model_type:write'])]
|
||||
private ?string $description = null;
|
||||
|
||||
#[ORM\Column(type: Types::TEXT, nullable: true)]
|
||||
#[Groups(['model_type:read', 'model_type:write'])]
|
||||
private ?string $referenceFormula = null;
|
||||
|
||||
#[ORM\Column(type: Types::JSON, nullable: true)]
|
||||
#[Groups(['model_type:read', 'model_type:write'])]
|
||||
private ?array $requiredFieldsForReference = null;
|
||||
|
||||
#[ORM\Column(type: Types::DATETIME_IMMUTABLE, name: 'createdAt')]
|
||||
#[Groups(['model_type:read'])]
|
||||
private DateTimeImmutable $createdAt;
|
||||
@@ -215,6 +223,30 @@ class ModelType
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getReferenceFormula(): ?string
|
||||
{
|
||||
return $this->referenceFormula;
|
||||
}
|
||||
|
||||
public function setReferenceFormula(?string $referenceFormula): static
|
||||
{
|
||||
$this->referenceFormula = $referenceFormula;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getRequiredFieldsForReference(): ?array
|
||||
{
|
||||
return $this->requiredFieldsForReference;
|
||||
}
|
||||
|
||||
public function setRequiredFieldsForReference(?array $requiredFieldsForReference): static
|
||||
{
|
||||
$this->requiredFieldsForReference = $requiredFieldsForReference;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
#[Groups(['model_type:read', 'product:read', 'composant:read', 'piece:read'])]
|
||||
public function getStructure(): ?array
|
||||
{
|
||||
|
||||
@@ -63,6 +63,10 @@ class Piece
|
||||
#[Groups(['piece:read'])]
|
||||
private ?string $reference = null;
|
||||
|
||||
#[ORM\Column(type: Types::STRING, length: 255, nullable: true)]
|
||||
#[Groups(['piece:read'])]
|
||||
private ?string $referenceAuto = null;
|
||||
|
||||
#[ORM\Column(type: Types::TEXT, nullable: true)]
|
||||
#[Groups(['piece:read'])]
|
||||
private ?string $description = null;
|
||||
@@ -179,6 +183,21 @@ class Piece
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getReferenceAuto(): ?string
|
||||
{
|
||||
return $this->referenceAuto;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal used by ReferenceAutoSubscriber only — not part of the public API
|
||||
*/
|
||||
public function setReferenceAuto(?string $referenceAuto): static
|
||||
{
|
||||
$this->referenceAuto = $referenceAuto;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDescription(): ?string
|
||||
{
|
||||
return $this->description;
|
||||
|
||||
Reference in New Issue
Block a user