From 47cbf6c2ddc76ecb13b2e30ff01aa12db4abf5d6 Mon Sep 17 00:00:00 2001 From: Fabian Wunsch Date: Tue, 11 Nov 2025 14:49:15 +0100 Subject: [PATCH] Move logic to AdvancedPropertyTrait.php --- src/Entity/Parts/Part.php | 30 ------------------ .../PartTraits/AdvancedPropertyTrait.php | 31 +++++++++++++++++++ 2 files changed, 31 insertions(+), 30 deletions(-) diff --git a/src/Entity/Parts/Part.php b/src/Entity/Parts/Part.php index d3c6ffdf..4a503ccd 100644 --- a/src/Entity/Parts/Part.php +++ b/src/Entity/Parts/Part.php @@ -138,16 +138,6 @@ class Part extends AttachmentContainingDBElement #[UniqueObjectCollection(fields: ['name', 'group', 'element'])] protected Collection $parameters; - /** - * @var \DateTimeInterface|null Set a time when the new order will arive. - * Set to null, if there is no known date or no order. - */ - #[Groups(['extended', 'full', 'import', 'part_lot:read', 'part_lot:write'])] - #[ORM\Column(name: 'orderDelivery', type: Types::DATETIME_MUTABLE, nullable: true)] - #[Year2038BugWorkaround] - protected ?\DateTimeInterface $orderDelivery = null; - - /** ************************************************************* * Overridden properties * (They are defined here and not in a trait, to avoid conflicts). @@ -244,26 +234,6 @@ class Part extends AttachmentContainingDBElement parent::__clone(); } - /** - * Gets the expected delivery date of the part. Returns null, if no delivery is due. - */ - public function getOrderDelivery(): ?\DateTimeInterface - { - return $this->orderDelivery; - } - - /** - * Sets the expected delivery date of the part. Set to null, if no delivery is due. - * - * - */ - public function setOrderDelivery(?\DateTimeInterface $orderDelivery): self - { - $this->orderDelivery = $orderDelivery; - - return $this; - } - #[Assert\Callback] public function validate(ExecutionContextInterface $context, $payload): void { diff --git a/src/Entity/Parts/PartTraits/AdvancedPropertyTrait.php b/src/Entity/Parts/PartTraits/AdvancedPropertyTrait.php index 230ba7b7..a502e49e 100644 --- a/src/Entity/Parts/PartTraits/AdvancedPropertyTrait.php +++ b/src/Entity/Parts/PartTraits/AdvancedPropertyTrait.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace App\Entity\Parts\PartTraits; use App\Entity\Parts\InfoProviderReference; +use App\Validator\Constraints\Year2038BugWorkaround; use Doctrine\DBAL\Types\Types; use App\Entity\Parts\Part; use Doctrine\ORM\Mapping as ORM; @@ -57,6 +58,15 @@ trait AdvancedPropertyTrait #[ORM\Column(type: Types::FLOAT, nullable: true)] protected ?float $mass = null; + /** + * @var \DateTimeInterface|null Set a time when the new order will arive. + * Set to null, if there is no known date or no order. + */ + #[Groups(['extended', 'full', 'import', 'part_lot:read', 'part_lot:write'])] + #[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)] + #[Year2038BugWorkaround] + protected ?\DateTimeInterface $orderDelivery = null; + /** * @var string|null The internal part number of the part */ @@ -141,6 +151,27 @@ trait AdvancedPropertyTrait return $this; } + /** + * Gets the expected delivery date of the part. Returns null, if no delivery is due. + */ + public function getOrderDelivery(): ?\DateTimeInterface + { + return $this->orderDelivery; + } + + /** + * Sets the expected delivery date of the part. Set to null, if no delivery is due. + * + * @param \DateTimeInterface|null $orderDelivery The new delivery date + * + * @return $this + */ + public function setOrderDelivery(?\DateTimeInterface $orderDelivery): self + { + $this->orderDelivery = $orderDelivery; + return $this; + } + /** * Returns the internal part number of the part. * @return string