From 037ed782a7c0aef8058a75160d9b438417b51b09 Mon Sep 17 00:00:00 2001 From: r-dev Date: Sun, 11 Jan 2026 17:05:36 +0100 Subject: [PATCH] feat(api): ajouter les entites et repositories inventory --- src/Entity/Composant.php | 227 ++++++++++ src/Entity/Constructeur.php | 151 +++++++ src/Entity/CustomField.php | 191 +++++++++ src/Entity/CustomFieldValue.php | 167 ++++++++ src/Entity/Document.php | 227 ++++++++++ src/Entity/Machine.php | 250 +++++++++++ src/Entity/MachineComponentLink.php | 198 +++++++++ src/Entity/MachinePieceLink.php | 184 ++++++++ src/Entity/MachineProductLink.php | 171 ++++++++ src/Entity/ModelType.php | 263 ++++++++++++ src/Entity/Piece.php | 212 ++++++++++ src/Entity/Product.php | 210 ++++++++++ src/Entity/Profile.php | 27 +- src/Entity/Site.php | 260 ++++++++++++ src/Entity/TypeMachine.php | 396 ++++++++++++++++++ .../TypeMachineComponentRequirement.php | 197 +++++++++ src/Entity/TypeMachinePieceRequirement.php | 197 +++++++++ src/Entity/TypeMachineProductRequirement.php | 197 +++++++++ src/Enum/ModelCategory.php | 12 + src/Repository/ComposantRepository.php | 20 + src/Repository/ConstructeurRepository.php | 20 + src/Repository/CustomFieldRepository.php | 20 + src/Repository/CustomFieldValueRepository.php | 20 + src/Repository/DocumentRepository.php | 20 + .../MachineComponentLinkRepository.php | 20 + src/Repository/MachinePieceLinkRepository.php | 20 + .../MachineProductLinkRepository.php | 20 + src/Repository/MachineRepository.php | 20 + src/Repository/ModelTypeRepository.php | 20 + src/Repository/PieceRepository.php | 20 + src/Repository/ProductRepository.php | 20 + src/Repository/SiteRepository.php | 45 ++ ...eMachineComponentRequirementRepository.php | 20 + .../TypeMachinePieceRequirementRepository.php | 20 + ...ypeMachineProductRequirementRepository.php | 20 + src/Repository/TypeMachineRepository.php | 38 ++ 36 files changed, 4106 insertions(+), 14 deletions(-) create mode 100644 src/Entity/Composant.php create mode 100644 src/Entity/Constructeur.php create mode 100644 src/Entity/CustomField.php create mode 100644 src/Entity/CustomFieldValue.php create mode 100644 src/Entity/Document.php create mode 100644 src/Entity/Machine.php create mode 100644 src/Entity/MachineComponentLink.php create mode 100644 src/Entity/MachinePieceLink.php create mode 100644 src/Entity/MachineProductLink.php create mode 100644 src/Entity/ModelType.php create mode 100644 src/Entity/Piece.php create mode 100644 src/Entity/Product.php create mode 100644 src/Entity/Site.php create mode 100644 src/Entity/TypeMachine.php create mode 100644 src/Entity/TypeMachineComponentRequirement.php create mode 100644 src/Entity/TypeMachinePieceRequirement.php create mode 100644 src/Entity/TypeMachineProductRequirement.php create mode 100644 src/Enum/ModelCategory.php create mode 100644 src/Repository/ComposantRepository.php create mode 100644 src/Repository/ConstructeurRepository.php create mode 100644 src/Repository/CustomFieldRepository.php create mode 100644 src/Repository/CustomFieldValueRepository.php create mode 100644 src/Repository/DocumentRepository.php create mode 100644 src/Repository/MachineComponentLinkRepository.php create mode 100644 src/Repository/MachinePieceLinkRepository.php create mode 100644 src/Repository/MachineProductLinkRepository.php create mode 100644 src/Repository/MachineRepository.php create mode 100644 src/Repository/ModelTypeRepository.php create mode 100644 src/Repository/PieceRepository.php create mode 100644 src/Repository/ProductRepository.php create mode 100644 src/Repository/SiteRepository.php create mode 100644 src/Repository/TypeMachineComponentRequirementRepository.php create mode 100644 src/Repository/TypeMachinePieceRequirementRepository.php create mode 100644 src/Repository/TypeMachineProductRequirementRepository.php create mode 100644 src/Repository/TypeMachineRepository.php diff --git a/src/Entity/Composant.php b/src/Entity/Composant.php new file mode 100644 index 0000000..8a55ba4 --- /dev/null +++ b/src/Entity/Composant.php @@ -0,0 +1,227 @@ + + */ + #[ORM\ManyToMany(targetEntity: Constructeur::class, inversedBy: 'composants')] + #[ORM\JoinTable( + name: '_ComposantConstructeurs', + joinColumns: [new ORM\JoinColumn(name: 'A', referencedColumnName: 'id', onDelete: 'CASCADE')], + inverseJoinColumns: [new ORM\InverseJoinColumn(name: 'B', referencedColumnName: 'id', onDelete: 'CASCADE')] + )] + private Collection $constructeurs; + + /** + * @var Collection + */ + #[ORM\OneToMany(mappedBy: 'composant', targetEntity: Document::class)] + private Collection $documents; + + /** + * @var Collection + */ + #[ORM\OneToMany(mappedBy: 'composant', targetEntity: CustomFieldValue::class)] + private Collection $customFieldValues; + + /** + * @var Collection + */ + #[ORM\OneToMany(mappedBy: 'composant', targetEntity: MachineComponentLink::class)] + private Collection $machineLinks; + + #[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->constructeurs = new ArrayCollection(); + $this->documents = new ArrayCollection(); + $this->customFieldValues = new ArrayCollection(); + $this->machineLinks = new ArrayCollection(); + } + + #[ORM\PrePersist] + public function setCreatedAtValue(): void + { + $now = new \DateTimeImmutable(); + $this->createdAt = $now; + $this->updatedAt = $now; + + if ($this->id === null) { + $this->id = $this->generateCuid(); + } + } + + #[ORM\PreUpdate] + public function setUpdatedAtValue(): void + { + $this->updatedAt = new \DateTimeImmutable(); + } + + private function generateCuid(): string + { + return 'cl' . bin2hex(random_bytes(12)); + } + + public function getId(): ?string + { + return $this->id; + } + + public function setId(string $id): static + { + $this->id = $id; + + return $this; + } + + public function getName(): string + { + return $this->name; + } + + public function setName(string $name): static + { + $this->name = $name; + + return $this; + } + + public function getReference(): ?string + { + return $this->reference; + } + + public function setReference(?string $reference): static + { + $this->reference = $reference; + + return $this; + } + + public function getPrix(): ?string + { + return $this->prix; + } + + public function setPrix(?string $prix): static + { + $this->prix = $prix; + + return $this; + } + + public function getStructure(): ?array + { + return $this->structure; + } + + public function setStructure(?array $structure): static + { + $this->structure = $structure; + + return $this; + } + + public function getTypeComposant(): ?ModelType + { + return $this->typeComposant; + } + + public function setTypeComposant(?ModelType $typeComposant): static + { + $this->typeComposant = $typeComposant; + + return $this; + } + + public function getProduct(): ?Product + { + return $this->product; + } + + public function setProduct(?Product $product): static + { + $this->product = $product; + + return $this; + } + + /** + * @return Collection + */ + public function getConstructeurs(): Collection + { + return $this->constructeurs; + } + + /** + * @return Collection + */ + public function getDocuments(): Collection + { + return $this->documents; + } + + /** + * @return Collection + */ + public function getCustomFieldValues(): Collection + { + return $this->customFieldValues; + } + + public function getCreatedAt(): \DateTimeImmutable + { + return $this->createdAt; + } + + public function getUpdatedAt(): \DateTimeImmutable + { + return $this->updatedAt; + } +} diff --git a/src/Entity/Constructeur.php b/src/Entity/Constructeur.php new file mode 100644 index 0000000..ef9ee93 --- /dev/null +++ b/src/Entity/Constructeur.php @@ -0,0 +1,151 @@ + + */ + #[ORM\ManyToMany(targetEntity: Machine::class, mappedBy: 'constructeurs')] + private Collection $machines; + + /** + * @var Collection + */ + #[ORM\ManyToMany(targetEntity: Composant::class, mappedBy: 'constructeurs')] + private Collection $composants; + + /** + * @var Collection + */ + #[ORM\ManyToMany(targetEntity: Piece::class, mappedBy: 'constructeurs')] + private Collection $pieces; + + /** + * @var Collection + */ + #[ORM\ManyToMany(targetEntity: Product::class, mappedBy: 'constructeurs')] + private Collection $products; + + public function __construct() + { + $this->machines = new ArrayCollection(); + $this->composants = new ArrayCollection(); + $this->pieces = new ArrayCollection(); + $this->products = new ArrayCollection(); + } + + #[ORM\PrePersist] + public function setCreatedAtValue(): void + { + $now = new \DateTimeImmutable(); + $this->createdAt = $now; + $this->updatedAt = $now; + + if ($this->id === null) { + $this->id = $this->generateCuid(); + } + } + + #[ORM\PreUpdate] + public function setUpdatedAtValue(): void + { + $this->updatedAt = new \DateTimeImmutable(); + } + + private function generateCuid(): string + { + return 'cl' . bin2hex(random_bytes(12)); + } + + public function getId(): ?string + { + return $this->id; + } + + public function setId(string $id): static + { + $this->id = $id; + + return $this; + } + + public function getName(): string + { + return $this->name; + } + + public function setName(string $name): static + { + $this->name = $name; + + return $this; + } + + public function getEmail(): ?string + { + return $this->email; + } + + public function setEmail(?string $email): static + { + $this->email = $email; + + return $this; + } + + public function getPhone(): ?string + { + return $this->phone; + } + + public function setPhone(?string $phone): static + { + $this->phone = $phone; + + return $this; + } + + public function getCreatedAt(): \DateTimeImmutable + { + return $this->createdAt; + } + + public function getUpdatedAt(): \DateTimeImmutable + { + return $this->updatedAt; + } +} diff --git a/src/Entity/CustomField.php b/src/Entity/CustomField.php new file mode 100644 index 0000000..2f8147b --- /dev/null +++ b/src/Entity/CustomField.php @@ -0,0 +1,191 @@ + false])] + private bool $required = false; + + #[ORM\Column(type: Types::STRING, length: 255, nullable: true, name: 'defaultValue')] + private ?string $defaultValue = null; + + #[ORM\Column(type: Types::JSON, nullable: true)] + private ?array $options = null; + + #[ORM\Column(type: Types::INTEGER, options: ['default' => 0], name: 'orderIndex')] + private int $orderIndex = 0; + + #[ORM\ManyToOne(targetEntity: TypeMachine::class, inversedBy: 'customFields')] + #[ORM\JoinColumn(name: 'typeMachineId', referencedColumnName: 'id', nullable: true, onDelete: 'CASCADE')] + private ?TypeMachine $typeMachine = null; + + #[ORM\ManyToOne(targetEntity: ModelType::class, inversedBy: 'customFields')] + #[ORM\JoinColumn(name: 'typeComposantId', referencedColumnName: 'id', nullable: true, onDelete: 'CASCADE')] + private ?ModelType $typeComposant = null; + + #[ORM\ManyToOne(targetEntity: ModelType::class, inversedBy: 'pieceCustomFields')] + #[ORM\JoinColumn(name: 'typePieceId', referencedColumnName: 'id', nullable: true, onDelete: 'CASCADE')] + private ?ModelType $typePiece = null; + + #[ORM\ManyToOne(targetEntity: ModelType::class, inversedBy: 'productCustomFields')] + #[ORM\JoinColumn(name: 'typeProductId', referencedColumnName: 'id', nullable: true, onDelete: 'CASCADE')] + private ?ModelType $typeProduct = null; + + /** + * @var Collection + */ + #[ORM\OneToMany(mappedBy: 'customField', targetEntity: CustomFieldValue::class)] + private Collection $customFieldValues; + + #[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->customFieldValues = new ArrayCollection(); + } + + #[ORM\PrePersist] + public function setCreatedAtValue(): void + { + $now = new \DateTimeImmutable(); + $this->createdAt = $now; + $this->updatedAt = $now; + + if ($this->id === null) { + $this->id = $this->generateCuid(); + } + } + + #[ORM\PreUpdate] + public function setUpdatedAtValue(): void + { + $this->updatedAt = new \DateTimeImmutable(); + } + + private function generateCuid(): string + { + return 'cl' . bin2hex(random_bytes(12)); + } + + public function getId(): ?string + { + return $this->id; + } + + public function setId(string $id): static + { + $this->id = $id; + + return $this; + } + + public function getName(): string + { + return $this->name; + } + + public function setName(string $name): static + { + $this->name = $name; + + return $this; + } + + public function getType(): string + { + return $this->type; + } + + public function setType(string $type): static + { + $this->type = $type; + + return $this; + } + + public function isRequired(): bool + { + return $this->required; + } + + public function setRequired(bool $required): static + { + $this->required = $required; + + return $this; + } + + public function getDefaultValue(): ?string + { + return $this->defaultValue; + } + + public function setDefaultValue(?string $defaultValue): static + { + $this->defaultValue = $defaultValue; + + return $this; + } + + public function getOptions(): ?array + { + return $this->options; + } + + public function setOptions(?array $options): static + { + $this->options = $options; + + return $this; + } + + public function getOrderIndex(): int + { + return $this->orderIndex; + } + + public function setOrderIndex(int $orderIndex): static + { + $this->orderIndex = $orderIndex; + + return $this; + } + + public function getCreatedAt(): \DateTimeImmutable + { + return $this->createdAt; + } + + public function getUpdatedAt(): \DateTimeImmutable + { + return $this->updatedAt; + } +} diff --git a/src/Entity/CustomFieldValue.php b/src/Entity/CustomFieldValue.php new file mode 100644 index 0000000..1f30f51 --- /dev/null +++ b/src/Entity/CustomFieldValue.php @@ -0,0 +1,167 @@ +createdAt = $now; + $this->updatedAt = $now; + + if ($this->id === null) { + $this->id = $this->generateCuid(); + } + } + + #[ORM\PreUpdate] + public function setUpdatedAtValue(): void + { + $this->updatedAt = new \DateTimeImmutable(); + } + + private function generateCuid(): string + { + return 'cl' . bin2hex(random_bytes(12)); + } + + public function getId(): ?string + { + return $this->id; + } + + public function setId(string $id): static + { + $this->id = $id; + + return $this; + } + + public function getValue(): string + { + return $this->value; + } + + public function setValue(string $value): static + { + $this->value = $value; + + return $this; + } + + public function getCustomField(): CustomField + { + return $this->customField; + } + + public function setCustomField(CustomField $customField): static + { + $this->customField = $customField; + + return $this; + } + + public function getMachine(): ?Machine + { + return $this->machine; + } + + public function setMachine(?Machine $machine): static + { + $this->machine = $machine; + + return $this; + } + + public function getComposant(): ?Composant + { + return $this->composant; + } + + public function setComposant(?Composant $composant): static + { + $this->composant = $composant; + + return $this; + } + + public function getPiece(): ?Piece + { + return $this->piece; + } + + public function setPiece(?Piece $piece): static + { + $this->piece = $piece; + + return $this; + } + + public function getProduct(): ?Product + { + return $this->product; + } + + public function setProduct(?Product $product): static + { + $this->product = $product; + + return $this; + } + + public function getCreatedAt(): \DateTimeImmutable + { + return $this->createdAt; + } + + public function getUpdatedAt(): \DateTimeImmutable + { + return $this->updatedAt; + } +} diff --git a/src/Entity/Document.php b/src/Entity/Document.php new file mode 100644 index 0000000..dcc2139 --- /dev/null +++ b/src/Entity/Document.php @@ -0,0 +1,227 @@ +createdAt = $now; + $this->updatedAt = $now; + + if ($this->id === null) { + $this->id = $this->generateCuid(); + } + } + + #[ORM\PreUpdate] + public function setUpdatedAtValue(): void + { + $this->updatedAt = new \DateTimeImmutable(); + } + + private function generateCuid(): string + { + return 'cl' . bin2hex(random_bytes(12)); + } + + public function getId(): ?string + { + return $this->id; + } + + public function setId(string $id): static + { + $this->id = $id; + + return $this; + } + + public function getName(): string + { + return $this->name; + } + + public function setName(string $name): static + { + $this->name = $name; + + return $this; + } + + public function getFilename(): string + { + return $this->filename; + } + + public function setFilename(string $filename): static + { + $this->filename = $filename; + + return $this; + } + + public function getPath(): string + { + return $this->path; + } + + public function setPath(string $path): static + { + $this->path = $path; + + return $this; + } + + public function getMimeType(): string + { + return $this->mimeType; + } + + public function setMimeType(string $mimeType): static + { + $this->mimeType = $mimeType; + + return $this; + } + + public function getSize(): int + { + return $this->size; + } + + public function setSize(int $size): static + { + $this->size = $size; + + return $this; + } + + public function getMachine(): ?Machine + { + return $this->machine; + } + + public function setMachine(?Machine $machine): static + { + $this->machine = $machine; + + return $this; + } + + public function getComposant(): ?Composant + { + return $this->composant; + } + + public function setComposant(?Composant $composant): static + { + $this->composant = $composant; + + return $this; + } + + public function getPiece(): ?Piece + { + return $this->piece; + } + + public function setPiece(?Piece $piece): static + { + $this->piece = $piece; + + return $this; + } + + public function getProduct(): ?Product + { + return $this->product; + } + + public function setProduct(?Product $product): static + { + $this->product = $product; + + return $this; + } + + public function getSite(): ?Site + { + return $this->site; + } + + public function setSite(?Site $site): static + { + $this->site = $site; + + return $this; + } + + public function getCreatedAt(): \DateTimeImmutable + { + return $this->createdAt; + } + + public function getUpdatedAt(): \DateTimeImmutable + { + return $this->updatedAt; + } +} diff --git a/src/Entity/Machine.php b/src/Entity/Machine.php new file mode 100644 index 0000000..ea280c1 --- /dev/null +++ b/src/Entity/Machine.php @@ -0,0 +1,250 @@ + + */ + #[ORM\ManyToMany(targetEntity: Constructeur::class, inversedBy: 'machines')] + #[ORM\JoinTable( + name: '_MachineConstructeurs', + joinColumns: [new ORM\JoinColumn(name: 'A', referencedColumnName: 'id', onDelete: 'CASCADE')], + inverseJoinColumns: [new ORM\InverseJoinColumn(name: 'B', referencedColumnName: 'id', onDelete: 'CASCADE')] + )] + private Collection $constructeurs; + + /** + * @var Collection + */ + #[ORM\OneToMany(mappedBy: 'machine', targetEntity: MachineComponentLink::class)] + private Collection $componentLinks; + + /** + * @var Collection + */ + #[ORM\OneToMany(mappedBy: 'machine', targetEntity: MachinePieceLink::class)] + private Collection $pieceLinks; + + /** + * @var Collection + */ + #[ORM\OneToMany(mappedBy: 'machine', targetEntity: MachineProductLink::class)] + private Collection $productLinks; + + /** + * @var Collection + */ + #[ORM\OneToMany(mappedBy: 'machine', targetEntity: Document::class)] + private Collection $documents; + + /** + * @var Collection + */ + #[ORM\OneToMany(mappedBy: 'machine', targetEntity: CustomFieldValue::class)] + private Collection $customFieldValues; + + #[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->constructeurs = new ArrayCollection(); + $this->componentLinks = new ArrayCollection(); + $this->pieceLinks = new ArrayCollection(); + $this->productLinks = new ArrayCollection(); + $this->documents = new ArrayCollection(); + $this->customFieldValues = new ArrayCollection(); + } + + #[ORM\PrePersist] + public function setCreatedAtValue(): void + { + $now = new \DateTimeImmutable(); + $this->createdAt = $now; + $this->updatedAt = $now; + + if ($this->id === null) { + $this->id = $this->generateCuid(); + } + } + + #[ORM\PreUpdate] + public function setUpdatedAtValue(): void + { + $this->updatedAt = new \DateTimeImmutable(); + } + + private function generateCuid(): string + { + return 'cl' . bin2hex(random_bytes(12)); + } + + public function getId(): ?string + { + return $this->id; + } + + public function setId(string $id): static + { + $this->id = $id; + + return $this; + } + + public function getName(): string + { + return $this->name; + } + + public function setName(string $name): static + { + $this->name = $name; + + return $this; + } + + public function getReference(): ?string + { + return $this->reference; + } + + public function setReference(?string $reference): static + { + $this->reference = $reference; + + return $this; + } + + public function getPrix(): ?string + { + return $this->prix; + } + + public function setPrix(?string $prix): static + { + $this->prix = $prix; + + return $this; + } + + public function getSite(): Site + { + return $this->site; + } + + public function setSite(Site $site): static + { + $this->site = $site; + + return $this; + } + + public function getTypeMachine(): ?TypeMachine + { + return $this->typeMachine; + } + + public function setTypeMachine(?TypeMachine $typeMachine): static + { + $this->typeMachine = $typeMachine; + + return $this; + } + + /** + * @return Collection + */ + public function getConstructeurs(): Collection + { + return $this->constructeurs; + } + + /** + * @return Collection + */ + public function getComponentLinks(): Collection + { + return $this->componentLinks; + } + + /** + * @return Collection + */ + public function getPieceLinks(): Collection + { + return $this->pieceLinks; + } + + /** + * @return Collection + */ + public function getProductLinks(): Collection + { + return $this->productLinks; + } + + /** + * @return Collection + */ + public function getDocuments(): Collection + { + return $this->documents; + } + + /** + * @return Collection + */ + public function getCustomFieldValues(): Collection + { + return $this->customFieldValues; + } + + public function getCreatedAt(): \DateTimeImmutable + { + return $this->createdAt; + } + + public function getUpdatedAt(): \DateTimeImmutable + { + return $this->updatedAt; + } +} diff --git a/src/Entity/MachineComponentLink.php b/src/Entity/MachineComponentLink.php new file mode 100644 index 0000000..0b2fdc0 --- /dev/null +++ b/src/Entity/MachineComponentLink.php @@ -0,0 +1,198 @@ + + */ + #[ORM\OneToMany(mappedBy: 'parentLink', targetEntity: MachineComponentLink::class)] + private Collection $childLinks; + + #[ORM\ManyToOne(targetEntity: TypeMachineComponentRequirement::class, inversedBy: 'machineComponentLinks')] + #[ORM\JoinColumn(name: 'typeMachineComponentRequirementId', referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')] + private ?TypeMachineComponentRequirement $typeMachineComponentRequirement = null; + + /** + * @var Collection + */ + #[ORM\OneToMany(mappedBy: 'parentLink', targetEntity: MachinePieceLink::class)] + private Collection $pieceLinks; + + /** + * @var Collection + */ + #[ORM\OneToMany(mappedBy: 'parentComponentLink', targetEntity: MachineProductLink::class)] + private Collection $productLinks; + + #[ORM\Column(type: Types::STRING, length: 255, nullable: true, name: 'nameOverride')] + private ?string $nameOverride = null; + + #[ORM\Column(type: Types::STRING, length: 255, nullable: true, name: 'referenceOverride')] + private ?string $referenceOverride = null; + + #[ORM\Column(type: Types::DECIMAL, precision: 10, scale: 2, nullable: true, name: 'prixOverride')] + private ?string $prixOverride = null; + + #[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->childLinks = new ArrayCollection(); + $this->pieceLinks = new ArrayCollection(); + $this->productLinks = new ArrayCollection(); + } + + #[ORM\PrePersist] + public function setCreatedAtValue(): void + { + $now = new \DateTimeImmutable(); + $this->createdAt = $now; + $this->updatedAt = $now; + + if ($this->id === null) { + $this->id = $this->generateCuid(); + } + } + + #[ORM\PreUpdate] + public function setUpdatedAtValue(): void + { + $this->updatedAt = new \DateTimeImmutable(); + } + + private function generateCuid(): string + { + return 'cl' . bin2hex(random_bytes(12)); + } + + public function getId(): ?string + { + return $this->id; + } + + public function setId(string $id): static + { + $this->id = $id; + + return $this; + } + + public function getMachine(): Machine + { + return $this->machine; + } + + public function setMachine(Machine $machine): static + { + $this->machine = $machine; + + return $this; + } + + public function getComposant(): Composant + { + return $this->composant; + } + + public function setComposant(Composant $composant): static + { + $this->composant = $composant; + + return $this; + } + + public function getParentLink(): ?MachineComponentLink + { + return $this->parentLink; + } + + public function setParentLink(?MachineComponentLink $parentLink): static + { + $this->parentLink = $parentLink; + + return $this; + } + + public function getTypeMachineComponentRequirement(): ?TypeMachineComponentRequirement + { + return $this->typeMachineComponentRequirement; + } + + public function setTypeMachineComponentRequirement(?TypeMachineComponentRequirement $requirement): static + { + $this->typeMachineComponentRequirement = $requirement; + + return $this; + } + + public function getNameOverride(): ?string + { + return $this->nameOverride; + } + + public function setNameOverride(?string $nameOverride): static + { + $this->nameOverride = $nameOverride; + + return $this; + } + + public function getReferenceOverride(): ?string + { + return $this->referenceOverride; + } + + public function setReferenceOverride(?string $referenceOverride): static + { + $this->referenceOverride = $referenceOverride; + + return $this; + } + + public function getPrixOverride(): ?string + { + return $this->prixOverride; + } + + public function setPrixOverride(?string $prixOverride): static + { + $this->prixOverride = $prixOverride; + + return $this; + } +} diff --git a/src/Entity/MachinePieceLink.php b/src/Entity/MachinePieceLink.php new file mode 100644 index 0000000..45ffd48 --- /dev/null +++ b/src/Entity/MachinePieceLink.php @@ -0,0 +1,184 @@ + + */ + #[ORM\OneToMany(mappedBy: 'parentPieceLink', targetEntity: MachineProductLink::class)] + private Collection $productLinks; + + #[ORM\Column(type: Types::STRING, length: 255, nullable: true, name: 'nameOverride')] + private ?string $nameOverride = null; + + #[ORM\Column(type: Types::STRING, length: 255, nullable: true, name: 'referenceOverride')] + private ?string $referenceOverride = null; + + #[ORM\Column(type: Types::DECIMAL, precision: 10, scale: 2, nullable: true, name: 'prixOverride')] + private ?string $prixOverride = null; + + #[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->productLinks = new ArrayCollection(); + } + + #[ORM\PrePersist] + public function setCreatedAtValue(): void + { + $now = new \DateTimeImmutable(); + $this->createdAt = $now; + $this->updatedAt = $now; + + if ($this->id === null) { + $this->id = $this->generateCuid(); + } + } + + #[ORM\PreUpdate] + public function setUpdatedAtValue(): void + { + $this->updatedAt = new \DateTimeImmutable(); + } + + private function generateCuid(): string + { + return 'cl' . bin2hex(random_bytes(12)); + } + + public function getId(): ?string + { + return $this->id; + } + + public function setId(string $id): static + { + $this->id = $id; + + return $this; + } + + public function getMachine(): Machine + { + return $this->machine; + } + + public function setMachine(Machine $machine): static + { + $this->machine = $machine; + + return $this; + } + + public function getPiece(): Piece + { + return $this->piece; + } + + public function setPiece(Piece $piece): static + { + $this->piece = $piece; + + return $this; + } + + public function getParentLink(): ?MachineComponentLink + { + return $this->parentLink; + } + + public function setParentLink(?MachineComponentLink $parentLink): static + { + $this->parentLink = $parentLink; + + return $this; + } + + public function getTypeMachinePieceRequirement(): ?TypeMachinePieceRequirement + { + return $this->typeMachinePieceRequirement; + } + + public function setTypeMachinePieceRequirement(?TypeMachinePieceRequirement $requirement): static + { + $this->typeMachinePieceRequirement = $requirement; + + return $this; + } + + public function getNameOverride(): ?string + { + return $this->nameOverride; + } + + public function setNameOverride(?string $nameOverride): static + { + $this->nameOverride = $nameOverride; + + return $this; + } + + public function getReferenceOverride(): ?string + { + return $this->referenceOverride; + } + + public function setReferenceOverride(?string $referenceOverride): static + { + $this->referenceOverride = $referenceOverride; + + return $this; + } + + public function getPrixOverride(): ?string + { + return $this->prixOverride; + } + + public function setPrixOverride(?string $prixOverride): static + { + $this->prixOverride = $prixOverride; + + return $this; + } +} diff --git a/src/Entity/MachineProductLink.php b/src/Entity/MachineProductLink.php new file mode 100644 index 0000000..d692788 --- /dev/null +++ b/src/Entity/MachineProductLink.php @@ -0,0 +1,171 @@ + + */ + #[ORM\OneToMany(mappedBy: 'parentLink', targetEntity: MachineProductLink::class)] + private Collection $childLinks; + + #[ORM\ManyToOne(targetEntity: MachineComponentLink::class, inversedBy: 'productLinks')] + #[ORM\JoinColumn(name: 'parentComponentLinkId', referencedColumnName: 'id', nullable: true, onDelete: 'CASCADE')] + private ?MachineComponentLink $parentComponentLink = null; + + #[ORM\ManyToOne(targetEntity: MachinePieceLink::class, inversedBy: 'productLinks')] + #[ORM\JoinColumn(name: 'parentPieceLinkId', referencedColumnName: 'id', nullable: true, onDelete: 'CASCADE')] + private ?MachinePieceLink $parentPieceLink = null; + + #[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->childLinks = new ArrayCollection(); + } + + #[ORM\PrePersist] + public function setCreatedAtValue(): void + { + $now = new \DateTimeImmutable(); + $this->createdAt = $now; + $this->updatedAt = $now; + + if ($this->id === null) { + $this->id = $this->generateCuid(); + } + } + + #[ORM\PreUpdate] + public function setUpdatedAtValue(): void + { + $this->updatedAt = new \DateTimeImmutable(); + } + + private function generateCuid(): string + { + return 'cl' . bin2hex(random_bytes(12)); + } + + public function getId(): ?string + { + return $this->id; + } + + public function setId(string $id): static + { + $this->id = $id; + + return $this; + } + + public function getMachine(): Machine + { + return $this->machine; + } + + public function setMachine(Machine $machine): static + { + $this->machine = $machine; + + return $this; + } + + public function getProduct(): Product + { + return $this->product; + } + + public function setProduct(Product $product): static + { + $this->product = $product; + + return $this; + } + + public function getTypeMachineProductRequirement(): ?TypeMachineProductRequirement + { + return $this->typeMachineProductRequirement; + } + + public function setTypeMachineProductRequirement(?TypeMachineProductRequirement $requirement): static + { + $this->typeMachineProductRequirement = $requirement; + + return $this; + } + + public function getParentLink(): ?MachineProductLink + { + return $this->parentLink; + } + + public function setParentLink(?MachineProductLink $parentLink): static + { + $this->parentLink = $parentLink; + + return $this; + } + + public function getParentComponentLink(): ?MachineComponentLink + { + return $this->parentComponentLink; + } + + public function setParentComponentLink(?MachineComponentLink $parentComponentLink): static + { + $this->parentComponentLink = $parentComponentLink; + + return $this; + } + + public function getParentPieceLink(): ?MachinePieceLink + { + return $this->parentPieceLink; + } + + public function setParentPieceLink(?MachinePieceLink $parentPieceLink): static + { + $this->parentPieceLink = $parentPieceLink; + + return $this; + } +} diff --git a/src/Entity/ModelType.php b/src/Entity/ModelType.php new file mode 100644 index 0000000..8c6739f --- /dev/null +++ b/src/Entity/ModelType.php @@ -0,0 +1,263 @@ + + */ + #[ORM\OneToMany(mappedBy: 'typeComposant', targetEntity: Composant::class)] + private Collection $composants; + + /** + * @var Collection + */ + #[ORM\OneToMany(mappedBy: 'typePiece', targetEntity: Piece::class)] + private Collection $pieces; + + /** + * @var Collection + */ + #[ORM\OneToMany(mappedBy: 'typeProduct', targetEntity: Product::class)] + private Collection $products; + + /** + * @var Collection + */ + #[ORM\OneToMany(mappedBy: 'typeComposant', targetEntity: TypeMachineComponentRequirement::class)] + private Collection $componentRequirements; + + /** + * @var Collection + */ + #[ORM\OneToMany(mappedBy: 'typePiece', targetEntity: TypeMachinePieceRequirement::class)] + private Collection $pieceRequirements; + + /** + * @var Collection + */ + #[ORM\OneToMany(mappedBy: 'typeProduct', targetEntity: TypeMachineProductRequirement::class)] + private Collection $productRequirements; + + /** + * @var Collection + */ + #[ORM\OneToMany(mappedBy: 'typeComposant', targetEntity: CustomField::class)] + private Collection $customFields; + + /** + * @var Collection + */ + #[ORM\OneToMany(mappedBy: 'typePiece', targetEntity: CustomField::class)] + private Collection $pieceCustomFields; + + /** + * @var Collection + */ + #[ORM\OneToMany(mappedBy: 'typeProduct', targetEntity: CustomField::class)] + private Collection $productCustomFields; + + public function __construct() + { + $this->composants = new ArrayCollection(); + $this->pieces = new ArrayCollection(); + $this->products = new ArrayCollection(); + $this->componentRequirements = new ArrayCollection(); + $this->pieceRequirements = new ArrayCollection(); + $this->productRequirements = new ArrayCollection(); + $this->customFields = new ArrayCollection(); + $this->pieceCustomFields = new ArrayCollection(); + $this->productCustomFields = new ArrayCollection(); + } + + #[ORM\PrePersist] + public function setCreatedAtValue(): void + { + $now = new \DateTimeImmutable(); + $this->createdAt = $now; + $this->updatedAt = $now; + + if ($this->id === null) { + $this->id = $this->generateCuid(); + } + } + + #[ORM\PreUpdate] + public function setUpdatedAtValue(): void + { + $this->updatedAt = new \DateTimeImmutable(); + } + + private function generateCuid(): string + { + return 'cl' . bin2hex(random_bytes(12)); + } + + public function getId(): ?string + { + return $this->id; + } + + public function setId(string $id): static + { + $this->id = $id; + + return $this; + } + + public function getName(): string + { + return $this->name; + } + + public function setName(string $name): static + { + $this->name = $name; + + return $this; + } + + public function getCode(): string + { + return $this->code; + } + + public function setCode(string $code): static + { + $this->code = $code; + + return $this; + } + + public function getCategory(): ModelCategory + { + return $this->category; + } + + public function setCategory(ModelCategory $category): static + { + $this->category = $category; + + return $this; + } + + public function getNotes(): ?string + { + return $this->notes; + } + + public function setNotes(?string $notes): static + { + $this->notes = $notes; + + return $this; + } + + public function getDescription(): ?string + { + return $this->description; + } + + public function setDescription(?string $description): static + { + $this->description = $description; + + return $this; + } + + public function getComponentSkeleton(): ?array + { + return $this->componentSkeleton; + } + + public function setComponentSkeleton(?array $componentSkeleton): static + { + $this->componentSkeleton = $componentSkeleton; + + return $this; + } + + public function getPieceSkeleton(): ?array + { + return $this->pieceSkeleton; + } + + public function setPieceSkeleton(?array $pieceSkeleton): static + { + $this->pieceSkeleton = $pieceSkeleton; + + return $this; + } + + public function getProductSkeleton(): ?array + { + return $this->productSkeleton; + } + + public function setProductSkeleton(?array $productSkeleton): static + { + $this->productSkeleton = $productSkeleton; + + return $this; + } + + public function getCreatedAt(): \DateTimeImmutable + { + return $this->createdAt; + } + + public function getUpdatedAt(): \DateTimeImmutable + { + return $this->updatedAt; + } +} diff --git a/src/Entity/Piece.php b/src/Entity/Piece.php new file mode 100644 index 0000000..7c33466 --- /dev/null +++ b/src/Entity/Piece.php @@ -0,0 +1,212 @@ + + */ + #[ORM\ManyToMany(targetEntity: Constructeur::class, inversedBy: 'pieces')] + #[ORM\JoinTable( + name: '_PieceConstructeurs', + joinColumns: [new ORM\JoinColumn(name: 'A', referencedColumnName: 'id', onDelete: 'CASCADE')], + inverseJoinColumns: [new ORM\InverseJoinColumn(name: 'B', referencedColumnName: 'id', onDelete: 'CASCADE')] + )] + private Collection $constructeurs; + + /** + * @var Collection + */ + #[ORM\OneToMany(mappedBy: 'piece', targetEntity: Document::class)] + private Collection $documents; + + /** + * @var Collection + */ + #[ORM\OneToMany(mappedBy: 'piece', targetEntity: CustomFieldValue::class)] + private Collection $customFieldValues; + + /** + * @var Collection + */ + #[ORM\OneToMany(mappedBy: 'piece', targetEntity: MachinePieceLink::class)] + private Collection $machineLinks; + + #[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->constructeurs = new ArrayCollection(); + $this->documents = new ArrayCollection(); + $this->customFieldValues = new ArrayCollection(); + $this->machineLinks = new ArrayCollection(); + } + + #[ORM\PrePersist] + public function setCreatedAtValue(): void + { + $now = new \DateTimeImmutable(); + $this->createdAt = $now; + $this->updatedAt = $now; + + if ($this->id === null) { + $this->id = $this->generateCuid(); + } + } + + #[ORM\PreUpdate] + public function setUpdatedAtValue(): void + { + $this->updatedAt = new \DateTimeImmutable(); + } + + private function generateCuid(): string + { + return 'cl' . bin2hex(random_bytes(12)); + } + + public function getId(): ?string + { + return $this->id; + } + + public function setId(string $id): static + { + $this->id = $id; + + return $this; + } + + public function getName(): string + { + return $this->name; + } + + public function setName(string $name): static + { + $this->name = $name; + + return $this; + } + + public function getReference(): ?string + { + return $this->reference; + } + + public function setReference(?string $reference): static + { + $this->reference = $reference; + + return $this; + } + + public function getPrix(): ?string + { + return $this->prix; + } + + public function setPrix(?string $prix): static + { + $this->prix = $prix; + + return $this; + } + + public function getTypePiece(): ?ModelType + { + return $this->typePiece; + } + + public function setTypePiece(?ModelType $typePiece): static + { + $this->typePiece = $typePiece; + + return $this; + } + + public function getProduct(): ?Product + { + return $this->product; + } + + public function setProduct(?Product $product): static + { + $this->product = $product; + + return $this; + } + + /** + * @return Collection + */ + public function getConstructeurs(): Collection + { + return $this->constructeurs; + } + + /** + * @return Collection + */ + public function getDocuments(): Collection + { + return $this->documents; + } + + /** + * @return Collection + */ + public function getCustomFieldValues(): Collection + { + return $this->customFieldValues; + } + + public function getCreatedAt(): \DateTimeImmutable + { + return $this->createdAt; + } + + public function getUpdatedAt(): \DateTimeImmutable + { + return $this->updatedAt; + } +} diff --git a/src/Entity/Product.php b/src/Entity/Product.php new file mode 100644 index 0000000..4442abf --- /dev/null +++ b/src/Entity/Product.php @@ -0,0 +1,210 @@ + + */ + #[ORM\ManyToMany(targetEntity: Constructeur::class, inversedBy: 'products')] + #[ORM\JoinTable( + name: '_ProductConstructeurs', + joinColumns: [new ORM\JoinColumn(name: 'A', referencedColumnName: 'id', onDelete: 'CASCADE')], + inverseJoinColumns: [new ORM\InverseJoinColumn(name: 'B', referencedColumnName: 'id', onDelete: 'CASCADE')] + )] + private Collection $constructeurs; + + /** + * @var Collection + */ + #[ORM\OneToMany(mappedBy: 'product', targetEntity: Document::class)] + private Collection $documents; + + /** + * @var Collection + */ + #[ORM\OneToMany(mappedBy: 'product', targetEntity: CustomFieldValue::class)] + private Collection $customFieldValues; + + /** + * @var Collection + */ + #[ORM\OneToMany(mappedBy: 'product', targetEntity: Piece::class)] + private Collection $pieces; + + /** + * @var Collection + */ + #[ORM\OneToMany(mappedBy: 'product', targetEntity: Composant::class)] + private Collection $composants; + + /** + * @var Collection + */ + #[ORM\OneToMany(mappedBy: 'product', targetEntity: MachineProductLink::class)] + private Collection $machineLinks; + + #[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->constructeurs = new ArrayCollection(); + $this->documents = new ArrayCollection(); + $this->customFieldValues = new ArrayCollection(); + $this->pieces = new ArrayCollection(); + $this->composants = new ArrayCollection(); + $this->machineLinks = new ArrayCollection(); + } + + #[ORM\PrePersist] + public function setCreatedAtValue(): void + { + $now = new \DateTimeImmutable(); + $this->createdAt = $now; + $this->updatedAt = $now; + + if ($this->id === null) { + $this->id = $this->generateCuid(); + } + } + + #[ORM\PreUpdate] + public function setUpdatedAtValue(): void + { + $this->updatedAt = new \DateTimeImmutable(); + } + + private function generateCuid(): string + { + return 'cl' . bin2hex(random_bytes(12)); + } + + public function getId(): ?string + { + return $this->id; + } + + public function setId(string $id): static + { + $this->id = $id; + + return $this; + } + + public function getName(): string + { + return $this->name; + } + + public function setName(string $name): static + { + $this->name = $name; + + return $this; + } + + public function getReference(): ?string + { + return $this->reference; + } + + public function setReference(?string $reference): static + { + $this->reference = $reference; + + return $this; + } + + public function getSupplierPrice(): ?string + { + return $this->supplierPrice; + } + + public function setSupplierPrice(?string $supplierPrice): static + { + $this->supplierPrice = $supplierPrice; + + return $this; + } + + public function getTypeProduct(): ?ModelType + { + return $this->typeProduct; + } + + public function setTypeProduct(?ModelType $typeProduct): static + { + $this->typeProduct = $typeProduct; + + return $this; + } + + /** + * @return Collection + */ + public function getConstructeurs(): Collection + { + return $this->constructeurs; + } + + /** + * @return Collection + */ + public function getDocuments(): Collection + { + return $this->documents; + } + + /** + * @return Collection + */ + public function getCustomFieldValues(): Collection + { + return $this->customFieldValues; + } + + public function getCreatedAt(): \DateTimeImmutable + { + return $this->createdAt; + } + + public function getUpdatedAt(): \DateTimeImmutable + { + return $this->updatedAt; + } +} diff --git a/src/Entity/Profile.php b/src/Entity/Profile.php index d5d99a8..02cd15e 100644 --- a/src/Entity/Profile.php +++ b/src/Entity/Profile.php @@ -36,49 +36,48 @@ use Symfony\Component\Validator\Constraints as Assert; class Profile implements UserInterface, PasswordAuthenticatedUserInterface { #[ORM\Id] - #[ORM\Column(type: 'string', length: 30)] + #[ORM\Column(type: 'string', length: 36)] #[Groups(['profile:read'])] private ?string $id = null; - #[ORM\Column(type: 'string', length: 180, unique: true)] - #[Assert\NotBlank] + #[ORM\Column(type: 'string', length: 180, unique: true, nullable: true)] #[Assert\Email] #[Groups(['profile:read', 'profile:write'])] - private string $email; + private ?string $email = null; - #[ORM\Column(type: 'string', length: 100)] + #[ORM\Column(type: 'string', length: 100, name: 'firstName')] #[Assert\NotBlank] #[Groups(['profile:read', 'profile:write'])] private string $firstName; - #[ORM\Column(type: 'string', length: 100)] + #[ORM\Column(type: 'string', length: 100, name: 'lastName')] #[Assert\NotBlank] #[Groups(['profile:read', 'profile:write'])] private string $lastName; - #[ORM\Column(type: 'boolean', options: ['default' => true])] + #[ORM\Column(type: 'boolean', options: ['default' => true], name: 'isActive')] #[Groups(['profile:read', 'profile:write'])] private bool $isActive = true; /** * @var list The user roles */ - #[ORM\Column(type: 'json')] + #[ORM\Column(type: 'json', options: ['default' => '["ROLE_USER"]'])] #[Groups(['profile:read', 'profile:write'])] private array $roles = ['ROLE_USER']; /** * @var string The hashed password */ - #[ORM\Column(type: 'string')] + #[ORM\Column(type: 'string', nullable: true)] #[Groups(['profile:write'])] private ?string $password = null; - #[ORM\Column(type: 'datetime_immutable')] + #[ORM\Column(type: 'datetime_immutable', name: 'createdAt')] #[Groups(['profile:read'])] private DateTimeImmutable $createdAt; - #[ORM\Column(type: 'datetime_immutable')] + #[ORM\Column(type: 'datetime_immutable', name: 'updatedAt')] #[Groups(['profile:read'])] private DateTimeImmutable $updatedAt; @@ -95,12 +94,12 @@ class Profile implements UserInterface, PasswordAuthenticatedUserInterface return $this->id; } - public function getEmail(): string + public function getEmail(): ?string { return $this->email; } - public function setEmail(string $email): static + public function setEmail(?string $email): static { $this->email = $email; @@ -148,7 +147,7 @@ class Profile implements UserInterface, PasswordAuthenticatedUserInterface */ public function getUserIdentifier(): string { - return $this->email; + return (string) $this->email; } /** diff --git a/src/Entity/Site.php b/src/Entity/Site.php new file mode 100644 index 0000000..6eb0990 --- /dev/null +++ b/src/Entity/Site.php @@ -0,0 +1,260 @@ + ''], name: 'contactName')] + private string $contactName = ''; + + #[ORM\Column(type: Types::STRING, length: 20, options: ['default' => ''], name: 'contactPhone')] + private string $contactPhone = ''; + + #[ORM\Column(type: Types::STRING, length: 500, options: ['default' => ''], name: 'contactAddress')] + private string $contactAddress = ''; + + #[ORM\Column(type: Types::STRING, length: 10, options: ['default' => ''], name: 'contactPostalCode')] + private string $contactPostalCode = ''; + + #[ORM\Column(type: Types::STRING, length: 100, options: ['default' => ''], name: 'contactCity')] + private string $contactCity = ''; + + #[ORM\Column(type: Types::DATETIME_IMMUTABLE, name: 'createdAt')] + private \DateTimeImmutable $createdAt; + + #[ORM\Column(type: Types::DATETIME_IMMUTABLE, name: 'updatedAt')] + private \DateTimeImmutable $updatedAt; + + /** + * @var Collection + */ + #[ORM\OneToMany(targetEntity: Machine::class, mappedBy: 'site', cascade: ['persist', 'remove'], orphanRemoval: true)] + private Collection $machines; + + /** + * @var Collection + */ + #[ORM\OneToMany(targetEntity: Document::class, mappedBy: 'site', cascade: ['remove'], orphanRemoval: true)] + private Collection $documents; + + public function __construct() + { + $this->machines = new ArrayCollection(); + $this->documents = new ArrayCollection(); + } + + #[ORM\PrePersist] + public function setCreatedAtValue(): void + { + $this->createdAt = new \DateTimeImmutable(); + $this->updatedAt = new \DateTimeImmutable(); + + // Générer un ID CUID-compatible si nécessaire + if ($this->id === null) { + $this->id = $this->generateCuid(); + } + } + + #[ORM\PreUpdate] + public function setUpdatedAtValue(): void + { + $this->updatedAt = new \DateTimeImmutable(); + } + + private function generateCuid(): string + { + // Génération d'un ID compatible CUID (format: cl + 24 caractères) + return 'cl' . bin2hex(random_bytes(12)); + } + + // Getters et Setters + + public function getId(): ?string + { + return $this->id; + } + + public function setId(string $id): static + { + $this->id = $id; + + return $this; + } + + public function getName(): string + { + return $this->name; + } + + public function setName(string $name): static + { + $this->name = $name; + + return $this; + } + + public function getContactName(): string + { + return $this->contactName; + } + + public function setContactName(string $contactName): static + { + $this->contactName = $contactName; + + return $this; + } + + public function getContactPhone(): string + { + return $this->contactPhone; + } + + public function setContactPhone(string $contactPhone): static + { + $this->contactPhone = $contactPhone; + + return $this; + } + + public function getContactAddress(): string + { + return $this->contactAddress; + } + + public function setContactAddress(string $contactAddress): static + { + $this->contactAddress = $contactAddress; + + return $this; + } + + public function getContactPostalCode(): string + { + return $this->contactPostalCode; + } + + public function setContactPostalCode(string $contactPostalCode): static + { + $this->contactPostalCode = $contactPostalCode; + + return $this; + } + + public function getContactCity(): string + { + return $this->contactCity; + } + + public function setContactCity(string $contactCity): static + { + $this->contactCity = $contactCity; + + return $this; + } + + public function getCreatedAt(): \DateTimeImmutable + { + return $this->createdAt; + } + + public function getUpdatedAt(): \DateTimeImmutable + { + return $this->updatedAt; + } + + /** + * @return Collection + */ + public function getMachines(): Collection + { + return $this->machines; + } + + public function addMachine(Machine $machine): static + { + if (!$this->machines->contains($machine)) { + $this->machines->add($machine); + $machine->setSite($this); + } + + return $this; + } + + public function removeMachine(Machine $machine): static + { + if ($this->machines->removeElement($machine)) { + // set the owning side to null (unless already changed) + if ($machine->getSite() === $this) { + $machine->setSite(null); + } + } + + return $this; + } + + /** + * @return Collection + */ + public function getDocuments(): Collection + { + return $this->documents; + } + + public function addDocument(Document $document): static + { + if (!$this->documents->contains($document)) { + $this->documents->add($document); + $document->setSite($this); + } + + return $this; + } + + public function removeDocument(Document $document): static + { + if ($this->documents->removeElement($document)) { + // set the owning side to null (unless already changed) + if ($document->getSite() === $this) { + $document->setSite(null); + } + } + + return $this; + } +} diff --git a/src/Entity/TypeMachine.php b/src/Entity/TypeMachine.php new file mode 100644 index 0000000..e45cd93 --- /dev/null +++ b/src/Entity/TypeMachine.php @@ -0,0 +1,396 @@ + ['type_machine:read']], + denormalizationContext: ['groups' => ['type_machine:write']] +)] +class TypeMachine +{ + #[ORM\Id] + #[ORM\Column(type: Types::STRING, length: 36)] + #[Groups(['type_machine:read'])] + private ?string $id = null; + + #[ORM\Column(type: Types::STRING, length: 255, unique: true)] + #[Assert\NotBlank] + #[Groups(['type_machine:read', 'type_machine:write', 'machine:read'])] + private string $name; + + #[ORM\Column(type: Types::TEXT, nullable: true)] + #[Groups(['type_machine:read', 'type_machine:write'])] + private ?string $description = null; + + #[ORM\Column(type: Types::STRING, length: 255, nullable: true, name: 'maintenanceFrequency')] + #[Groups(['type_machine:read', 'type_machine:write'])] + private ?string $category = null; + + #[ORM\Column(type: Types::STRING, length: 255, nullable: true)] + #[Groups(['type_machine:read', 'type_machine:write'])] + private ?string $maintenanceFrequency = null; + + #[ORM\Column(type: Types::JSON, nullable: true, name: 'criticalParts')] + #[Groups(['type_machine:read', 'type_machine:write'])] + private ?array $components = null; + + #[ORM\Column(type: Types::JSON, nullable: true, name: 'machinePieces')] + #[Groups(['type_machine:read', 'type_machine:write'])] + private ?array $criticalParts = null; + + #[ORM\Column(type: Types::JSON, nullable: true)] + #[Groups(['type_machine:read', 'type_machine:write'])] + private ?array $machinePieces = null; + + #[ORM\Column(type: Types::JSON, nullable: true)] + #[Groups(['type_machine:read', 'type_machine:write'])] + private ?array $specifications = null; + + #[ORM\Column(type: Types::DATETIME_IMMUTABLE, name: 'createdAt')] + #[Groups(['type_machine:read'])] + private DateTimeImmutable $createdAt; + + #[ORM\Column(type: Types::DATETIME_IMMUTABLE, name: 'updatedAt')] + #[Groups(['type_machine:read'])] + private DateTimeImmutable $updatedAt; + + /** + * @var Collection + */ + #[ORM\OneToMany(targetEntity: Machine::class, mappedBy: 'typeMachine')] + private Collection $machines; + + /** + * @var Collection + */ + #[ORM\OneToMany(targetEntity: CustomField::class, mappedBy: 'typeMachine')] + private Collection $customFields; + + /** + * @var Collection + */ + #[ORM\OneToMany(targetEntity: TypeMachineComponentRequirement::class, mappedBy: 'typeMachine', cascade: ['persist', 'remove'])] + private Collection $componentRequirements; + + /** + * @var Collection + */ + #[ORM\OneToMany(targetEntity: TypeMachinePieceRequirement::class, mappedBy: 'typeMachine', cascade: ['persist', 'remove'])] + private Collection $pieceRequirements; + + /** + * @var Collection + */ + #[ORM\OneToMany(targetEntity: TypeMachineProductRequirement::class, mappedBy: 'typeMachine', cascade: ['persist', 'remove'])] + private Collection $productRequirements; + + public function __construct() + { + $this->id = 'cl' . bin2hex(random_bytes(12)); + $this->createdAt = new DateTimeImmutable(); + $this->updatedAt = new DateTimeImmutable(); + $this->machines = new ArrayCollection(); + $this->customFields = new ArrayCollection(); + $this->componentRequirements = new ArrayCollection(); + $this->pieceRequirements = new ArrayCollection(); + $this->productRequirements = new ArrayCollection(); + } + + public function getId(): ?string + { + return $this->id; + } + + public function getName(): string + { + return $this->name; + } + + public function setName(string $name): static + { + $this->name = $name; + + return $this; + } + + public function getDescription(): ?string + { + return $this->description; + } + + public function setDescription(?string $description): static + { + $this->description = $description; + + return $this; + } + + public function getCategory(): ?string + { + return $this->category; + } + + public function setCategory(?string $category): static + { + $this->category = $category; + + return $this; + } + + public function getMaintenanceFrequency(): ?string + { + return $this->maintenanceFrequency; + } + + public function setMaintenanceFrequency(?string $maintenanceFrequency): static + { + $this->maintenanceFrequency = $maintenanceFrequency; + + return $this; + } + + public function getComponents(): ?array + { + return $this->components; + } + + public function setComponents(?array $components): static + { + $this->components = $components; + + return $this; + } + + public function getCriticalParts(): ?array + { + return $this->criticalParts; + } + + public function setCriticalParts(?array $criticalParts): static + { + $this->criticalParts = $criticalParts; + + return $this; + } + + public function getMachinePieces(): ?array + { + return $this->machinePieces; + } + + public function setMachinePieces(?array $machinePieces): static + { + $this->machinePieces = $machinePieces; + + return $this; + } + + public function getSpecifications(): ?array + { + return $this->specifications; + } + + public function setSpecifications(?array $specifications): static + { + $this->specifications = $specifications; + + return $this; + } + + public function getCreatedAt(): DateTimeImmutable + { + return $this->createdAt; + } + + public function getUpdatedAt(): DateTimeImmutable + { + return $this->updatedAt; + } + + /** + * @return Collection + */ + public function getMachines(): Collection + { + return $this->machines; + } + + public function addMachine(Machine $machine): static + { + if (!$this->machines->contains($machine)) { + $this->machines->add($machine); + $machine->setTypeMachine($this); + } + + return $this; + } + + public function removeMachine(Machine $machine): static + { + if ($this->machines->removeElement($machine)) { + if ($machine->getTypeMachine() === $this) { + $machine->setTypeMachine(null); + } + } + + return $this; + } + + /** + * @return Collection + */ + public function getCustomFields(): Collection + { + return $this->customFields; + } + + public function addCustomField(CustomField $customField): static + { + if (!$this->customFields->contains($customField)) { + $this->customFields->add($customField); + $customField->setTypeMachine($this); + } + + return $this; + } + + public function removeCustomField(CustomField $customField): static + { + if ($this->customFields->removeElement($customField)) { + if ($customField->getTypeMachine() === $this) { + $customField->setTypeMachine(null); + } + } + + return $this; + } + + /** + * @return Collection + */ + public function getComponentRequirements(): Collection + { + return $this->componentRequirements; + } + + public function addComponentRequirement(TypeMachineComponentRequirement $componentRequirement): static + { + if (!$this->componentRequirements->contains($componentRequirement)) { + $this->componentRequirements->add($componentRequirement); + $componentRequirement->setTypeMachine($this); + } + + return $this; + } + + public function removeComponentRequirement(TypeMachineComponentRequirement $componentRequirement): static + { + if ($this->componentRequirements->removeElement($componentRequirement)) { + if ($componentRequirement->getTypeMachine() === $this) { + $componentRequirement->setTypeMachine(null); + } + } + + return $this; + } + + /** + * @return Collection + */ + public function getPieceRequirements(): Collection + { + return $this->pieceRequirements; + } + + public function addPieceRequirement(TypeMachinePieceRequirement $pieceRequirement): static + { + if (!$this->pieceRequirements->contains($pieceRequirement)) { + $this->pieceRequirements->add($pieceRequirement); + $pieceRequirement->setTypeMachine($this); + } + + return $this; + } + + public function removePieceRequirement(TypeMachinePieceRequirement $pieceRequirement): static + { + if ($this->pieceRequirements->removeElement($pieceRequirement)) { + if ($pieceRequirement->getTypeMachine() === $this) { + $pieceRequirement->setTypeMachine(null); + } + } + + return $this; + } + + /** + * @return Collection + */ + public function getProductRequirements(): Collection + { + return $this->productRequirements; + } + + public function addProductRequirement(TypeMachineProductRequirement $productRequirement): static + { + if (!$this->productRequirements->contains($productRequirement)) { + $this->productRequirements->add($productRequirement); + $productRequirement->setTypeMachine($this); + } + + return $this; + } + + public function removeProductRequirement(TypeMachineProductRequirement $productRequirement): static + { + if ($this->productRequirements->removeElement($productRequirement)) { + if ($productRequirement->getTypeMachine() === $this) { + $productRequirement->setTypeMachine(null); + } + } + + return $this; + } + + #[ORM\PrePersist] + public function setCreatedAtValue(): void + { + $this->createdAt = new DateTimeImmutable(); + $this->updatedAt = new DateTimeImmutable(); + } + + #[ORM\PreUpdate] + public function setUpdatedAtValue(): void + { + $this->updatedAt = new DateTimeImmutable(); + } +} diff --git a/src/Entity/TypeMachineComponentRequirement.php b/src/Entity/TypeMachineComponentRequirement.php new file mode 100644 index 0000000..ac0dc12 --- /dev/null +++ b/src/Entity/TypeMachineComponentRequirement.php @@ -0,0 +1,197 @@ + 1], name: 'minCount')] + private int $minCount = 1; + + #[ORM\Column(type: Types::INTEGER, nullable: true, name: 'maxCount')] + private ?int $maxCount = null; + + #[ORM\Column(type: Types::BOOLEAN, options: ['default' => true], name: 'required')] + private bool $required = true; + + #[ORM\Column(type: Types::BOOLEAN, options: ['default' => true], name: 'allowNewModels')] + private bool $allowNewModels = true; + + #[ORM\Column(type: Types::INTEGER, options: ['default' => 0], name: 'orderIndex')] + private int $orderIndex = 0; + + #[ORM\ManyToOne(targetEntity: TypeMachine::class, inversedBy: 'componentRequirements')] + #[ORM\JoinColumn(name: 'typeMachineId', referencedColumnName: 'id', nullable: false, onDelete: 'CASCADE')] + private TypeMachine $typeMachine; + + #[ORM\ManyToOne(targetEntity: ModelType::class, inversedBy: 'componentRequirements')] + #[ORM\JoinColumn(name: 'typeComposantId', referencedColumnName: 'id', nullable: false)] + private ModelType $typeComposant; + + /** + * @var Collection + */ + #[ORM\OneToMany(mappedBy: 'typeMachineComponentRequirement', targetEntity: MachineComponentLink::class)] + private Collection $machineComponentLinks; + + #[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->machineComponentLinks = new ArrayCollection(); + } + + #[ORM\PrePersist] + public function setCreatedAtValue(): void + { + $now = new \DateTimeImmutable(); + $this->createdAt = $now; + $this->updatedAt = $now; + + if ($this->id === null) { + $this->id = $this->generateCuid(); + } + } + + #[ORM\PreUpdate] + public function setUpdatedAtValue(): void + { + $this->updatedAt = new \DateTimeImmutable(); + } + + private function generateCuid(): string + { + return 'cl' . bin2hex(random_bytes(12)); + } + + public function getId(): ?string + { + return $this->id; + } + + public function setId(string $id): static + { + $this->id = $id; + + return $this; + } + + public function getLabel(): ?string + { + return $this->label; + } + + public function setLabel(?string $label): static + { + $this->label = $label; + + return $this; + } + + public function getMinCount(): int + { + return $this->minCount; + } + + public function setMinCount(int $minCount): static + { + $this->minCount = $minCount; + + return $this; + } + + public function getMaxCount(): ?int + { + return $this->maxCount; + } + + public function setMaxCount(?int $maxCount): static + { + $this->maxCount = $maxCount; + + return $this; + } + + public function isRequired(): bool + { + return $this->required; + } + + public function setRequired(bool $required): static + { + $this->required = $required; + + return $this; + } + + public function isAllowNewModels(): bool + { + return $this->allowNewModels; + } + + public function setAllowNewModels(bool $allowNewModels): static + { + $this->allowNewModels = $allowNewModels; + + return $this; + } + + public function getOrderIndex(): int + { + return $this->orderIndex; + } + + public function setOrderIndex(int $orderIndex): static + { + $this->orderIndex = $orderIndex; + + return $this; + } + + public function getTypeMachine(): TypeMachine + { + return $this->typeMachine; + } + + public function setTypeMachine(TypeMachine $typeMachine): static + { + $this->typeMachine = $typeMachine; + + return $this; + } + + public function getTypeComposant(): ModelType + { + return $this->typeComposant; + } + + public function setTypeComposant(ModelType $typeComposant): static + { + $this->typeComposant = $typeComposant; + + return $this; + } +} diff --git a/src/Entity/TypeMachinePieceRequirement.php b/src/Entity/TypeMachinePieceRequirement.php new file mode 100644 index 0000000..c8a0b6b --- /dev/null +++ b/src/Entity/TypeMachinePieceRequirement.php @@ -0,0 +1,197 @@ + 0], name: 'minCount')] + private int $minCount = 0; + + #[ORM\Column(type: Types::INTEGER, nullable: true, name: 'maxCount')] + private ?int $maxCount = null; + + #[ORM\Column(type: Types::BOOLEAN, options: ['default' => false])] + private bool $required = false; + + #[ORM\Column(type: Types::BOOLEAN, options: ['default' => true], name: 'allowNewModels')] + private bool $allowNewModels = true; + + #[ORM\Column(type: Types::INTEGER, options: ['default' => 0], name: 'orderIndex')] + private int $orderIndex = 0; + + #[ORM\ManyToOne(targetEntity: TypeMachine::class, inversedBy: 'pieceRequirements')] + #[ORM\JoinColumn(name: 'typeMachineId', referencedColumnName: 'id', nullable: false, onDelete: 'CASCADE')] + private TypeMachine $typeMachine; + + #[ORM\ManyToOne(targetEntity: ModelType::class, inversedBy: 'pieceRequirements')] + #[ORM\JoinColumn(name: 'typePieceId', referencedColumnName: 'id', nullable: false)] + private ModelType $typePiece; + + /** + * @var Collection + */ + #[ORM\OneToMany(mappedBy: 'typeMachinePieceRequirement', targetEntity: MachinePieceLink::class)] + private Collection $machinePieceLinks; + + #[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->machinePieceLinks = new ArrayCollection(); + } + + #[ORM\PrePersist] + public function setCreatedAtValue(): void + { + $now = new \DateTimeImmutable(); + $this->createdAt = $now; + $this->updatedAt = $now; + + if ($this->id === null) { + $this->id = $this->generateCuid(); + } + } + + #[ORM\PreUpdate] + public function setUpdatedAtValue(): void + { + $this->updatedAt = new \DateTimeImmutable(); + } + + private function generateCuid(): string + { + return 'cl' . bin2hex(random_bytes(12)); + } + + public function getId(): ?string + { + return $this->id; + } + + public function setId(string $id): static + { + $this->id = $id; + + return $this; + } + + public function getLabel(): ?string + { + return $this->label; + } + + public function setLabel(?string $label): static + { + $this->label = $label; + + return $this; + } + + public function getMinCount(): int + { + return $this->minCount; + } + + public function setMinCount(int $minCount): static + { + $this->minCount = $minCount; + + return $this; + } + + public function getMaxCount(): ?int + { + return $this->maxCount; + } + + public function setMaxCount(?int $maxCount): static + { + $this->maxCount = $maxCount; + + return $this; + } + + public function isRequired(): bool + { + return $this->required; + } + + public function setRequired(bool $required): static + { + $this->required = $required; + + return $this; + } + + public function isAllowNewModels(): bool + { + return $this->allowNewModels; + } + + public function setAllowNewModels(bool $allowNewModels): static + { + $this->allowNewModels = $allowNewModels; + + return $this; + } + + public function getOrderIndex(): int + { + return $this->orderIndex; + } + + public function setOrderIndex(int $orderIndex): static + { + $this->orderIndex = $orderIndex; + + return $this; + } + + public function getTypeMachine(): TypeMachine + { + return $this->typeMachine; + } + + public function setTypeMachine(TypeMachine $typeMachine): static + { + $this->typeMachine = $typeMachine; + + return $this; + } + + public function getTypePiece(): ModelType + { + return $this->typePiece; + } + + public function setTypePiece(ModelType $typePiece): static + { + $this->typePiece = $typePiece; + + return $this; + } +} diff --git a/src/Entity/TypeMachineProductRequirement.php b/src/Entity/TypeMachineProductRequirement.php new file mode 100644 index 0000000..3261f4c --- /dev/null +++ b/src/Entity/TypeMachineProductRequirement.php @@ -0,0 +1,197 @@ + 0], name: 'minCount')] + private int $minCount = 0; + + #[ORM\Column(type: Types::INTEGER, nullable: true, name: 'maxCount')] + private ?int $maxCount = null; + + #[ORM\Column(type: Types::BOOLEAN, options: ['default' => false])] + private bool $required = false; + + #[ORM\Column(type: Types::BOOLEAN, options: ['default' => true], name: 'allowNewModels')] + private bool $allowNewModels = true; + + #[ORM\Column(type: Types::INTEGER, options: ['default' => 0], name: 'orderIndex')] + private int $orderIndex = 0; + + #[ORM\ManyToOne(targetEntity: TypeMachine::class, inversedBy: 'productRequirements')] + #[ORM\JoinColumn(name: 'typeMachineId', referencedColumnName: 'id', nullable: false, onDelete: 'CASCADE')] + private TypeMachine $typeMachine; + + #[ORM\ManyToOne(targetEntity: ModelType::class, inversedBy: 'productRequirements')] + #[ORM\JoinColumn(name: 'typeProductId', referencedColumnName: 'id', nullable: false)] + private ModelType $typeProduct; + + /** + * @var Collection + */ + #[ORM\OneToMany(mappedBy: 'typeMachineProductRequirement', targetEntity: MachineProductLink::class)] + private Collection $machineProductLinks; + + #[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->machineProductLinks = new ArrayCollection(); + } + + #[ORM\PrePersist] + public function setCreatedAtValue(): void + { + $now = new \DateTimeImmutable(); + $this->createdAt = $now; + $this->updatedAt = $now; + + if ($this->id === null) { + $this->id = $this->generateCuid(); + } + } + + #[ORM\PreUpdate] + public function setUpdatedAtValue(): void + { + $this->updatedAt = new \DateTimeImmutable(); + } + + private function generateCuid(): string + { + return 'cl' . bin2hex(random_bytes(12)); + } + + public function getId(): ?string + { + return $this->id; + } + + public function setId(string $id): static + { + $this->id = $id; + + return $this; + } + + public function getLabel(): ?string + { + return $this->label; + } + + public function setLabel(?string $label): static + { + $this->label = $label; + + return $this; + } + + public function getMinCount(): int + { + return $this->minCount; + } + + public function setMinCount(int $minCount): static + { + $this->minCount = $minCount; + + return $this; + } + + public function getMaxCount(): ?int + { + return $this->maxCount; + } + + public function setMaxCount(?int $maxCount): static + { + $this->maxCount = $maxCount; + + return $this; + } + + public function isRequired(): bool + { + return $this->required; + } + + public function setRequired(bool $required): static + { + $this->required = $required; + + return $this; + } + + public function isAllowNewModels(): bool + { + return $this->allowNewModels; + } + + public function setAllowNewModels(bool $allowNewModels): static + { + $this->allowNewModels = $allowNewModels; + + return $this; + } + + public function getOrderIndex(): int + { + return $this->orderIndex; + } + + public function setOrderIndex(int $orderIndex): static + { + $this->orderIndex = $orderIndex; + + return $this; + } + + public function getTypeMachine(): TypeMachine + { + return $this->typeMachine; + } + + public function setTypeMachine(TypeMachine $typeMachine): static + { + $this->typeMachine = $typeMachine; + + return $this; + } + + public function getTypeProduct(): ModelType + { + return $this->typeProduct; + } + + public function setTypeProduct(ModelType $typeProduct): static + { + $this->typeProduct = $typeProduct; + + return $this; + } +} diff --git a/src/Enum/ModelCategory.php b/src/Enum/ModelCategory.php new file mode 100644 index 0000000..edd84d9 --- /dev/null +++ b/src/Enum/ModelCategory.php @@ -0,0 +1,12 @@ + + */ +class ComposantRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, Composant::class); + } +} diff --git a/src/Repository/ConstructeurRepository.php b/src/Repository/ConstructeurRepository.php new file mode 100644 index 0000000..dea254c --- /dev/null +++ b/src/Repository/ConstructeurRepository.php @@ -0,0 +1,20 @@ + + */ +class ConstructeurRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, Constructeur::class); + } +} diff --git a/src/Repository/CustomFieldRepository.php b/src/Repository/CustomFieldRepository.php new file mode 100644 index 0000000..35160ca --- /dev/null +++ b/src/Repository/CustomFieldRepository.php @@ -0,0 +1,20 @@ + + */ +class CustomFieldRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, CustomField::class); + } +} diff --git a/src/Repository/CustomFieldValueRepository.php b/src/Repository/CustomFieldValueRepository.php new file mode 100644 index 0000000..53b05dd --- /dev/null +++ b/src/Repository/CustomFieldValueRepository.php @@ -0,0 +1,20 @@ + + */ +class CustomFieldValueRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, CustomFieldValue::class); + } +} diff --git a/src/Repository/DocumentRepository.php b/src/Repository/DocumentRepository.php new file mode 100644 index 0000000..02cecff --- /dev/null +++ b/src/Repository/DocumentRepository.php @@ -0,0 +1,20 @@ + + */ +class DocumentRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, Document::class); + } +} diff --git a/src/Repository/MachineComponentLinkRepository.php b/src/Repository/MachineComponentLinkRepository.php new file mode 100644 index 0000000..3fac34a --- /dev/null +++ b/src/Repository/MachineComponentLinkRepository.php @@ -0,0 +1,20 @@ + + */ +class MachineComponentLinkRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, MachineComponentLink::class); + } +} diff --git a/src/Repository/MachinePieceLinkRepository.php b/src/Repository/MachinePieceLinkRepository.php new file mode 100644 index 0000000..17b7cfe --- /dev/null +++ b/src/Repository/MachinePieceLinkRepository.php @@ -0,0 +1,20 @@ + + */ +class MachinePieceLinkRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, MachinePieceLink::class); + } +} diff --git a/src/Repository/MachineProductLinkRepository.php b/src/Repository/MachineProductLinkRepository.php new file mode 100644 index 0000000..12c176f --- /dev/null +++ b/src/Repository/MachineProductLinkRepository.php @@ -0,0 +1,20 @@ + + */ +class MachineProductLinkRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, MachineProductLink::class); + } +} diff --git a/src/Repository/MachineRepository.php b/src/Repository/MachineRepository.php new file mode 100644 index 0000000..0cf84a3 --- /dev/null +++ b/src/Repository/MachineRepository.php @@ -0,0 +1,20 @@ + + */ +class MachineRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, Machine::class); + } +} diff --git a/src/Repository/ModelTypeRepository.php b/src/Repository/ModelTypeRepository.php new file mode 100644 index 0000000..a09378f --- /dev/null +++ b/src/Repository/ModelTypeRepository.php @@ -0,0 +1,20 @@ + + */ +class ModelTypeRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, ModelType::class); + } +} diff --git a/src/Repository/PieceRepository.php b/src/Repository/PieceRepository.php new file mode 100644 index 0000000..30a5b22 --- /dev/null +++ b/src/Repository/PieceRepository.php @@ -0,0 +1,20 @@ + + */ +class PieceRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, Piece::class); + } +} diff --git a/src/Repository/ProductRepository.php b/src/Repository/ProductRepository.php new file mode 100644 index 0000000..a3ff691 --- /dev/null +++ b/src/Repository/ProductRepository.php @@ -0,0 +1,20 @@ + + */ +class ProductRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, Product::class); + } +} diff --git a/src/Repository/SiteRepository.php b/src/Repository/SiteRepository.php new file mode 100644 index 0000000..fa7e127 --- /dev/null +++ b/src/Repository/SiteRepository.php @@ -0,0 +1,45 @@ + + */ +class SiteRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, Site::class); + } + + // /** + // * @return Site[] Returns an array of Site objects + // */ + // public function findByExampleField($value): array + // { + // return $this->createQueryBuilder('s') + // ->andWhere('s.exampleField = :val') + // ->setParameter('val', $value) + // ->orderBy('s.id', 'ASC') + // ->setMaxResults(10) + // ->getQuery() + // ->getResult() + // ; + // } + + // public function findOneBySomeField($value): ?Site + // { + // return $this->createQueryBuilder('s') + // ->andWhere('s.exampleField = :val') + // ->setParameter('val', $value) + // ->getQuery() + // ->getOneOrNullResult() + // ; + // } +} diff --git a/src/Repository/TypeMachineComponentRequirementRepository.php b/src/Repository/TypeMachineComponentRequirementRepository.php new file mode 100644 index 0000000..56bccd3 --- /dev/null +++ b/src/Repository/TypeMachineComponentRequirementRepository.php @@ -0,0 +1,20 @@ + + */ +class TypeMachineComponentRequirementRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, TypeMachineComponentRequirement::class); + } +} diff --git a/src/Repository/TypeMachinePieceRequirementRepository.php b/src/Repository/TypeMachinePieceRequirementRepository.php new file mode 100644 index 0000000..4f510b6 --- /dev/null +++ b/src/Repository/TypeMachinePieceRequirementRepository.php @@ -0,0 +1,20 @@ + + */ +class TypeMachinePieceRequirementRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, TypeMachinePieceRequirement::class); + } +} diff --git a/src/Repository/TypeMachineProductRequirementRepository.php b/src/Repository/TypeMachineProductRequirementRepository.php new file mode 100644 index 0000000..de8721c --- /dev/null +++ b/src/Repository/TypeMachineProductRequirementRepository.php @@ -0,0 +1,20 @@ + + */ +class TypeMachineProductRequirementRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, TypeMachineProductRequirement::class); + } +} diff --git a/src/Repository/TypeMachineRepository.php b/src/Repository/TypeMachineRepository.php new file mode 100644 index 0000000..8a6bfa6 --- /dev/null +++ b/src/Repository/TypeMachineRepository.php @@ -0,0 +1,38 @@ + + */ +class TypeMachineRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, TypeMachine::class); + } + + public function save(TypeMachine $entity, bool $flush = false): void + { + $this->getEntityManager()->persist($entity); + + if ($flush) { + $this->getEntityManager()->flush(); + } + } + + public function remove(TypeMachine $entity, bool $flush = false): void + { + $this->getEntityManager()->remove($entity); + + if ($flush) { + $this->getEntityManager()->flush(); + } + } +}