From 0bc4699cdc1febf4068ef4597917c66b1ccb1046 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Sun, 28 May 2023 01:33:45 +0200 Subject: [PATCH] Started to move doctrine annotations to attributes (rector automated) --- rector.php | 9 +++- src/Entity/Attachments/Attachment.php | 42 ++++++--------- .../AttachmentContainingDBElement.php | 4 +- src/Entity/Attachments/AttachmentType.php | 40 +++++++-------- .../Attachments/AttachmentTypeAttachment.php | 7 ++- src/Entity/Attachments/CategoryAttachment.php | 7 ++- src/Entity/Attachments/CurrencyAttachment.php | 7 ++- .../Attachments/FootprintAttachment.php | 7 ++- src/Entity/Attachments/GroupAttachment.php | 7 ++- src/Entity/Attachments/LabelAttachment.php | 7 ++- .../Attachments/ManufacturerAttachment.php | 7 ++- .../Attachments/MeasurementUnitAttachment.php | 7 ++- src/Entity/Attachments/PartAttachment.php | 7 ++- src/Entity/Attachments/ProjectAttachment.php | 7 ++- .../Attachments/StorelocationAttachment.php | 7 ++- src/Entity/Attachments/SupplierAttachment.php | 7 ++- src/Entity/Attachments/UserAttachment.php | 7 ++- src/Entity/Base/AbstractCompany.php | 15 +++--- src/Entity/Base/AbstractDBElement.php | 9 ++-- src/Entity/Base/AbstractNamedDBElement.php | 7 ++- .../Base/AbstractPartsContainingDBElement.php | 3 +- .../Base/AbstractStructuralDBElement.php | 8 +-- src/Entity/Base/MasterAttachmentTrait.php | 4 +- src/Entity/LabelSystem/LabelOptions.php | 20 ++++---- src/Entity/LabelSystem/LabelProfile.php | 19 ++++--- .../LogSystem/CollectionElementDeleted.php | 6 +-- .../LogSystem/ConfigChangedLogEntry.php | 4 +- .../LogSystem/DatabaseUpdatedLogEntry.php | 4 +- .../LogSystem/ElementCreatedLogEntry.php | 4 +- .../LogSystem/ElementDeletedLogEntry.php | 4 +- .../LogSystem/ElementEditedLogEntry.php | 4 +- src/Entity/LogSystem/ExceptionLogEntry.php | 4 +- .../LegacyInstockChangedLogEntry.php | 4 +- .../LogSystem/PartStockChangedLogEntry.php | 4 +- .../LogSystem/SecurityEventLogEntry.php | 3 +- src/Entity/LogSystem/UserLoginLogEntry.php | 3 +- src/Entity/LogSystem/UserLogoutLogEntry.php | 4 +- .../LogSystem/UserNotAllowedLogEntry.php | 4 +- src/Entity/Parameters/AbstractParameter.php | 45 ++++++---------- .../Parameters/AttachmentTypeParameter.php | 8 ++- src/Entity/Parameters/CategoryParameter.php | 8 ++- src/Entity/Parameters/CurrencyParameter.php | 7 ++- src/Entity/Parameters/FootprintParameter.php | 8 ++- src/Entity/Parameters/GroupParameter.php | 8 ++- .../Parameters/ManufacturerParameter.php | 8 ++- .../Parameters/MeasurementUnitParameter.php | 8 ++- src/Entity/Parameters/PartParameter.php | 8 ++- src/Entity/Parameters/ProjectParameter.php | 8 ++- .../Parameters/StorelocationParameter.php | 8 ++- src/Entity/Parameters/SupplierParameter.php | 8 ++- src/Entity/Parts/Category.php | 51 ++++++++++--------- src/Entity/Parts/Footprint.php | 39 +++++++------- src/Entity/Parts/Manufacturer.php | 35 +++++++------ src/Entity/Parts/MeasurementUnit.php | 41 ++++++++------- .../PartTraits/AdvancedPropertyTrait.php | 8 +-- .../Parts/PartTraits/BasicPropertyTrait.php | 16 +++--- src/Entity/Parts/PartTraits/InstockTrait.php | 12 ++--- .../Parts/PartTraits/ManufacturerTrait.php | 10 ++-- src/Entity/Parts/PartTraits/OrderTrait.php | 14 ++--- src/Entity/Parts/PartTraits/ProjectTrait.php | 10 ++-- src/Entity/Parts/Storelocation.php | 49 +++++++++--------- src/Entity/Parts/Supplier.php | 45 ++++++++-------- src/Entity/PriceInformations/Currency.php | 39 +++++++------- src/Entity/PriceInformations/Orderdetail.php | 35 ++++++------- src/Entity/PriceInformations/Pricedetail.php | 33 ++++++------ src/Entity/ProjectSystem/Project.php | 45 +++++++--------- src/Entity/ProjectSystem/ProjectBOMEntry.php | 29 +++++------ src/Entity/UserSystem/Group.php | 36 +++++++------ src/Entity/UserSystem/PermissionData.php | 5 +- src/Entity/UserSystem/U2FKey.php | 39 +++++--------- src/Entity/UserSystem/WebauthnKey.php | 24 +++------ .../AttachmentDeleteListener.php | 9 ++-- .../TreeCacheInvalidationListener.php | 8 ++- 73 files changed, 483 insertions(+), 604 deletions(-) diff --git a/rector.php b/rector.php index c8545b90..a70f0ba7 100644 --- a/rector.php +++ b/rector.php @@ -4,6 +4,7 @@ declare(strict_types=1); use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector; use Rector\Config\RectorConfig; +use Rector\Doctrine\Set\DoctrineSetList; use Rector\Set\ValueObject\LevelSetList; use Rector\Set\ValueObject\SetList; use Rector\Symfony\Set\SymfonyLevelSetList; @@ -25,10 +26,16 @@ return static function (RectorConfig $rectorConfig): void { // define sets of rules $rectorConfig->sets([ + //PHP rules //SetList::CODE_QUALITY, //LevelSetList::UP_TO_PHP_81, + + //Symfony rules SymfonyLevelSetList::UP_TO_SYMFONY_62, - //SymfonySetList::ANNOTATIONS_TO_ATTRIBUTES, SymfonySetList::SYMFONY_CODE_QUALITY, + + //Doctrine rules + DoctrineSetList::ANNOTATIONS_TO_ATTRIBUTES, + DoctrineSetList::DOCTRINE_CODE_QUALITY, ]); }; diff --git a/src/Entity/Attachments/Attachment.php b/src/Entity/Attachments/Attachment.php index d33f3a30..7c07a465 100644 --- a/src/Entity/Attachments/Attachment.php +++ b/src/Entity/Attachments/Attachment.php @@ -33,27 +33,17 @@ use LogicException; /** * Class Attachment. - * - * @ORM\Entity(repositoryClass="App\Repository\AttachmentRepository") - * @ORM\Table(name="`attachments`", indexes={ - * @ORM\Index(name="attachments_idx_id_element_id_class_name", columns={"id", "element_id", "class_name"}), - * @ORM\Index(name="attachments_idx_class_name_id", columns={"class_name", "id"}), - * @ORM\Index(name="attachment_name_idx", columns={"name"}), - * @ORM\Index(name="attachment_element_idx", columns={"class_name", "element_id"}) - * }) - * @ORM\InheritanceType("SINGLE_TABLE") - * @ORM\DiscriminatorColumn(name="class_name", type="string") - * @ORM\DiscriminatorMap({ - * "PartDB\Part" = "PartAttachment", "Part" = "PartAttachment", - * "PartDB\Device" = "ProjectAttachment", "Device" = "ProjectAttachment", - * "AttachmentType" = "AttachmentTypeAttachment", "Category" = "CategoryAttachment", - * "Footprint" = "FootprintAttachment", "Manufacturer" = "ManufacturerAttachment", - * "Currency" = "CurrencyAttachment", "Group" = "GroupAttachment", - * "MeasurementUnit" = "MeasurementUnitAttachment", "Storelocation" = "StorelocationAttachment", - * "Supplier" = "SupplierAttachment", "User" = "UserAttachment", "LabelProfile" = "LabelAttachment", - * }) - * @ORM\EntityListeners({"App\EntityListeners\AttachmentDeleteListener"}) */ +#[ORM\Entity(repositoryClass: 'App\Repository\AttachmentRepository')] +#[ORM\InheritanceType('SINGLE_TABLE')] +#[ORM\DiscriminatorColumn(name: 'class_name', type: 'string')] +#[ORM\DiscriminatorMap(['PartDB\Part' => 'PartAttachment', 'Part' => 'PartAttachment', 'PartDB\Device' => 'ProjectAttachment', 'Device' => 'ProjectAttachment', 'AttachmentType' => 'AttachmentTypeAttachment', 'Category' => 'CategoryAttachment', 'Footprint' => 'FootprintAttachment', 'Manufacturer' => 'ManufacturerAttachment', 'Currency' => 'CurrencyAttachment', 'Group' => 'GroupAttachment', 'MeasurementUnit' => 'MeasurementUnitAttachment', 'Storelocation' => 'StorelocationAttachment', 'Supplier' => 'SupplierAttachment', 'User' => 'UserAttachment', 'LabelProfile' => 'LabelAttachment'])] +#[ORM\EntityListeners(['App\EntityListeners\AttachmentDeleteListener'])] +#[ORM\Table(name: '`attachments`')] +#[ORM\Index(name: 'attachments_idx_id_element_id_class_name', columns: ['id', 'element_id', 'class_name'])] +#[ORM\Index(name: 'attachments_idx_class_name_id', columns: ['class_name', 'id'])] +#[ORM\Index(name: 'attachment_name_idx', columns: ['name'])] +#[ORM\Index(name: 'attachment_element_idx', columns: ['class_name', 'element_id'])] abstract class Attachment extends AbstractNamedDBElement { /** @@ -86,22 +76,22 @@ abstract class Attachment extends AbstractNamedDBElement /** * @var string|null the original filename the file had, when the user uploaded it - * @ORM\Column(type="string", nullable=true) */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, nullable: true)] protected ?string $original_filename = null; /** * @var string The path to the file relative to a placeholder path like %MEDIA% - * @ORM\Column(type="string", name="path") */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, name: 'path')] protected string $path = ''; /** * @var string the name of this element - * @ORM\Column(type="string") */ #[Assert\NotBlank(message: 'validator.attachment.name_not_blank')] #[Groups(['simple', 'extended', 'full'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING)] protected string $name = ''; /** @@ -111,17 +101,17 @@ abstract class Attachment extends AbstractNamedDBElement /** * @var bool - * @ORM\Column(type="boolean") */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN)] protected bool $show_in_table = false; /** * @var AttachmentType|null - * @ORM\ManyToOne(targetEntity="AttachmentType", inversedBy="attachments_with_type") - * @ORM\JoinColumn(name="type_id", referencedColumnName="id", nullable=false) * @Selectable() */ #[Assert\NotNull(message: 'validator.attachment.must_not_be_null')] + #[ORM\ManyToOne(targetEntity: 'AttachmentType', inversedBy: 'attachments_with_type')] + #[ORM\JoinColumn(name: 'type_id', nullable: false)] protected ?AttachmentType $attachment_type = null; public function __construct() diff --git a/src/Entity/Attachments/AttachmentContainingDBElement.php b/src/Entity/Attachments/AttachmentContainingDBElement.php index 5f592ed2..d2d772e8 100644 --- a/src/Entity/Attachments/AttachmentContainingDBElement.php +++ b/src/Entity/Attachments/AttachmentContainingDBElement.php @@ -31,9 +31,7 @@ use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Serializer\Annotation\Groups; -/** - * @ORM\MappedSuperclass() - */ +#[ORM\MappedSuperclass] abstract class AttachmentContainingDBElement extends AbstractNamedDBElement implements HasMasterAttachmentInterface, HasAttachmentsInterface { use MasterAttachmentTrait; diff --git a/src/Entity/Attachments/AttachmentType.php b/src/Entity/Attachments/AttachmentType.php index a7e3742f..e2614168 100644 --- a/src/Entity/Attachments/AttachmentType.php +++ b/src/Entity/Attachments/AttachmentType.php @@ -32,56 +32,52 @@ use Symfony\Component\Validator\Constraints as Assert; /** * Class AttachmentType. - * - * @ORM\Entity(repositoryClass="App\Repository\StructuralDBElementRepository") - * @ORM\Table(name="`attachment_types`", indexes={ - * @ORM\Index(name="attachment_types_idx_name", columns={"name"}), - * @ORM\Index(name="attachment_types_idx_parent_name", columns={"parent_id", "name"}), - * }) */ +#[ORM\Entity(repositoryClass: 'App\Repository\StructuralDBElementRepository')] +#[ORM\Table(name: '`attachment_types`')] +#[ORM\Index(name: 'attachment_types_idx_name', columns: ['name'])] +#[ORM\Index(name: 'attachment_types_idx_parent_name', columns: ['parent_id', 'name'])] class AttachmentType extends AbstractStructuralDBElement { - /** - * @ORM\OneToMany(targetEntity="AttachmentType", mappedBy="parent", cascade={"persist"}) - * @ORM\OrderBy({"name" = "ASC"}) - */ + #[ORM\OneToMany(targetEntity: 'AttachmentType', mappedBy: 'parent', cascade: ['persist'])] + #[ORM\OrderBy(['name' => 'ASC'])] protected Collection $children; - /** - * @ORM\ManyToOne(targetEntity="AttachmentType", inversedBy="children") - * @ORM\JoinColumn(name="parent_id", referencedColumnName="id") - */ + #[ORM\ManyToOne(targetEntity: 'AttachmentType', inversedBy: 'children')] + #[ORM\JoinColumn(name: 'parent_id')] protected ?AbstractStructuralDBElement $parent; /** * @var string - * @ORM\Column(type="text") * @ValidFileFilter */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT)] protected string $filetype_filter = ''; /** * @var Collection - * @ORM\OneToMany(targetEntity="App\Entity\Attachments\AttachmentTypeAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true) - * @ORM\OrderBy({"name" = "ASC"}) */ #[Assert\Valid] + #[ORM\OneToMany(targetEntity: 'App\Entity\Attachments\AttachmentTypeAttachment', mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)] + #[ORM\OrderBy(['name' => 'ASC'])] protected Collection $attachments; /** @var Collection - * @ORM\OneToMany(targetEntity="App\Entity\Parameters\AttachmentTypeParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true) - * @ORM\OrderBy({"group" = "ASC" ,"name" = "ASC"}) */ #[Assert\Valid] + #[ORM\OneToMany(targetEntity: 'App\Entity\Parameters\AttachmentTypeParameter', mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)] + #[ORM\OrderBy(['group' => 'ASC', 'name' => 'ASC'])] protected Collection $parameters; /** - * @var Collection - * @ORM\OneToMany(targetEntity="Attachment", mappedBy="attachment_type") + * @var \Doctrine\Common\Collections\Collection<\App\Entity\Attachments\Attachment> */ - protected $attachments_with_type; + #[ORM\OneToMany(targetEntity: 'Attachment', mappedBy: 'attachment_type')] + protected \Doctrine\Common\Collections\Collection $attachments_with_type; public function __construct() { + $this->children = new \Doctrine\Common\Collections\ArrayCollection(); + $this->parameters = new \Doctrine\Common\Collections\ArrayCollection(); parent::__construct(); $this->attachments = new ArrayCollection(); $this->attachments_with_type = new ArrayCollection(); diff --git a/src/Entity/Attachments/AttachmentTypeAttachment.php b/src/Entity/Attachments/AttachmentTypeAttachment.php index 8b29d8a1..b6dab86f 100644 --- a/src/Entity/Attachments/AttachmentTypeAttachment.php +++ b/src/Entity/Attachments/AttachmentTypeAttachment.php @@ -27,17 +27,16 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; /** * A attachment attached to an attachmentType element. - * - * @ORM\Entity() */ #[UniqueEntity(['name', 'attachment_type', 'element'])] +#[ORM\Entity] class AttachmentTypeAttachment extends Attachment { public const ALLOWED_ELEMENT_CLASS = AttachmentType::class; /** * @var AttachmentContainingDBElement|null the element this attachment is associated with - * @ORM\ManyToOne(targetEntity="App\Entity\Attachments\AttachmentType", inversedBy="attachments") - * @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE"). */ + #[ORM\ManyToOne(targetEntity: 'App\Entity\Attachments\AttachmentType', inversedBy: 'attachments')] + #[ORM\JoinColumn(name: 'element_id', nullable: false, onDelete: 'CASCADE')] protected ?AttachmentContainingDBElement $element = null; } diff --git a/src/Entity/Attachments/CategoryAttachment.php b/src/Entity/Attachments/CategoryAttachment.php index 49685f15..e7a54fdd 100644 --- a/src/Entity/Attachments/CategoryAttachment.php +++ b/src/Entity/Attachments/CategoryAttachment.php @@ -28,17 +28,16 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; /** * An attachment attached to a category element. - * - * @ORM\Entity() */ #[UniqueEntity(['name', 'attachment_type', 'element'])] +#[ORM\Entity] class CategoryAttachment extends Attachment { public const ALLOWED_ELEMENT_CLASS = Category::class; /** * @var AttachmentContainingDBElement|null the element this attachment is associated with - * @ORM\ManyToOne(targetEntity="App\Entity\Parts\Category", inversedBy="attachments") - * @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE"). */ + #[ORM\ManyToOne(targetEntity: 'App\Entity\Parts\Category', inversedBy: 'attachments')] + #[ORM\JoinColumn(name: 'element_id', nullable: false, onDelete: 'CASCADE')] protected ?AttachmentContainingDBElement $element = null; } diff --git a/src/Entity/Attachments/CurrencyAttachment.php b/src/Entity/Attachments/CurrencyAttachment.php index caa595f6..6671bdca 100644 --- a/src/Entity/Attachments/CurrencyAttachment.php +++ b/src/Entity/Attachments/CurrencyAttachment.php @@ -28,17 +28,16 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; /** * An attachment attached to a currency element. - * - * @ORM\Entity() */ #[UniqueEntity(['name', 'attachment_type', 'element'])] +#[ORM\Entity] class CurrencyAttachment extends Attachment { public const ALLOWED_ELEMENT_CLASS = Currency::class; /** * @var Currency|null the element this attachment is associated with - * @ORM\ManyToOne(targetEntity="App\Entity\PriceInformations\Currency", inversedBy="attachments") - * @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE"). */ + #[ORM\ManyToOne(targetEntity: 'App\Entity\PriceInformations\Currency', inversedBy: 'attachments')] + #[ORM\JoinColumn(name: 'element_id', nullable: false, onDelete: 'CASCADE')] protected ?AttachmentContainingDBElement $element = null; } diff --git a/src/Entity/Attachments/FootprintAttachment.php b/src/Entity/Attachments/FootprintAttachment.php index 5bca593b..3fc3e2af 100644 --- a/src/Entity/Attachments/FootprintAttachment.php +++ b/src/Entity/Attachments/FootprintAttachment.php @@ -28,17 +28,16 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; /** * An attachment attached to a footprint element. - * - * @ORM\Entity() */ #[UniqueEntity(['name', 'attachment_type', 'element'])] +#[ORM\Entity] class FootprintAttachment extends Attachment { public const ALLOWED_ELEMENT_CLASS = Footprint::class; /** * @var Footprint|null the element this attachment is associated with - * @ORM\ManyToOne(targetEntity="App\Entity\Parts\Footprint", inversedBy="attachments") - * @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE"). */ + #[ORM\ManyToOne(targetEntity: 'App\Entity\Parts\Footprint', inversedBy: 'attachments')] + #[ORM\JoinColumn(name: 'element_id', nullable: false, onDelete: 'CASCADE')] protected ?AttachmentContainingDBElement $element = null; } diff --git a/src/Entity/Attachments/GroupAttachment.php b/src/Entity/Attachments/GroupAttachment.php index b48ca523..a2d439bf 100644 --- a/src/Entity/Attachments/GroupAttachment.php +++ b/src/Entity/Attachments/GroupAttachment.php @@ -28,18 +28,17 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; /** * An attachment attached to a Group element. - * - * @ORM\Entity() */ #[UniqueEntity(['name', 'attachment_type', 'element'])] +#[ORM\Entity] class GroupAttachment extends Attachment { public const ALLOWED_ELEMENT_CLASS = Group::class; /** * @var Group|null the element this attachment is associated with - * @ORM\ManyToOne(targetEntity="App\Entity\UserSystem\Group", inversedBy="attachments") - * @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE"). */ + #[ORM\ManyToOne(targetEntity: 'App\Entity\UserSystem\Group', inversedBy: 'attachments')] + #[ORM\JoinColumn(name: 'element_id', nullable: false, onDelete: 'CASCADE')] protected ?AttachmentContainingDBElement $element = null; } diff --git a/src/Entity/Attachments/LabelAttachment.php b/src/Entity/Attachments/LabelAttachment.php index a8c09bee..7ff1a191 100644 --- a/src/Entity/Attachments/LabelAttachment.php +++ b/src/Entity/Attachments/LabelAttachment.php @@ -47,18 +47,17 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; /** * A attachment attached to a user element. - * - * @ORM\Entity() */ #[UniqueEntity(['name', 'attachment_type', 'element'])] +#[ORM\Entity] class LabelAttachment extends Attachment { public const ALLOWED_ELEMENT_CLASS = LabelProfile::class; /** * @var LabelProfile the element this attachment is associated with - * @ORM\ManyToOne(targetEntity="App\Entity\LabelSystem\LabelProfile", inversedBy="attachments") - * @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE"). */ + #[ORM\ManyToOne(targetEntity: 'App\Entity\LabelSystem\LabelProfile', inversedBy: 'attachments')] + #[ORM\JoinColumn(name: 'element_id', nullable: false, onDelete: 'CASCADE')] protected ?AttachmentContainingDBElement $element = null; } diff --git a/src/Entity/Attachments/ManufacturerAttachment.php b/src/Entity/Attachments/ManufacturerAttachment.php index ca11d0b3..1d5709dd 100644 --- a/src/Entity/Attachments/ManufacturerAttachment.php +++ b/src/Entity/Attachments/ManufacturerAttachment.php @@ -28,18 +28,17 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; /** * An attachment attached to a manufacturer element. - * - * @ORM\Entity() */ #[UniqueEntity(['name', 'attachment_type', 'element'])] +#[ORM\Entity] class ManufacturerAttachment extends Attachment { public const ALLOWED_ELEMENT_CLASS = Manufacturer::class; /** * @var Manufacturer|null the element this attachment is associated with - * @ORM\ManyToOne(targetEntity="App\Entity\Parts\Manufacturer", inversedBy="attachments") - * @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE"). */ + #[ORM\ManyToOne(targetEntity: 'App\Entity\Parts\Manufacturer', inversedBy: 'attachments')] + #[ORM\JoinColumn(name: 'element_id', nullable: false, onDelete: 'CASCADE')] protected ?AttachmentContainingDBElement $element = null; } diff --git a/src/Entity/Attachments/MeasurementUnitAttachment.php b/src/Entity/Attachments/MeasurementUnitAttachment.php index 623e0661..ad4fbbc9 100644 --- a/src/Entity/Attachments/MeasurementUnitAttachment.php +++ b/src/Entity/Attachments/MeasurementUnitAttachment.php @@ -29,17 +29,16 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; /** * An attachment attached to a measurement unit element. - * - * @ORM\Entity() */ #[UniqueEntity(['name', 'attachment_type', 'element'])] +#[ORM\Entity] class MeasurementUnitAttachment extends Attachment { public const ALLOWED_ELEMENT_CLASS = MeasurementUnit::class; /** * @var Manufacturer|null the element this attachment is associated with - * @ORM\ManyToOne(targetEntity="App\Entity\Parts\MeasurementUnit", inversedBy="attachments") - * @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE"). */ + #[ORM\ManyToOne(targetEntity: 'App\Entity\Parts\MeasurementUnit', inversedBy: 'attachments')] + #[ORM\JoinColumn(name: 'element_id', nullable: false, onDelete: 'CASCADE')] protected ?AttachmentContainingDBElement $element = null; } diff --git a/src/Entity/Attachments/PartAttachment.php b/src/Entity/Attachments/PartAttachment.php index 2efb0088..82db5c72 100644 --- a/src/Entity/Attachments/PartAttachment.php +++ b/src/Entity/Attachments/PartAttachment.php @@ -28,17 +28,16 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; /** * A attachment attached to a part element. - * - * @ORM\Entity() */ #[UniqueEntity(['name', 'attachment_type', 'element'])] +#[ORM\Entity] class PartAttachment extends Attachment { public const ALLOWED_ELEMENT_CLASS = Part::class; /** * @var Part the element this attachment is associated with - * @ORM\ManyToOne(targetEntity="App\Entity\Parts\Part", inversedBy="attachments") - * @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE"). */ + #[ORM\ManyToOne(targetEntity: 'App\Entity\Parts\Part', inversedBy: 'attachments')] + #[ORM\JoinColumn(name: 'element_id', nullable: false, onDelete: 'CASCADE')] protected ?AttachmentContainingDBElement $element = null; } diff --git a/src/Entity/Attachments/ProjectAttachment.php b/src/Entity/Attachments/ProjectAttachment.php index f9d3d24e..052996c3 100644 --- a/src/Entity/Attachments/ProjectAttachment.php +++ b/src/Entity/Attachments/ProjectAttachment.php @@ -28,17 +28,16 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; /** * A attachment attached to a device element. - * - * @ORM\Entity() */ #[UniqueEntity(['name', 'attachment_type', 'element'])] +#[ORM\Entity] class ProjectAttachment extends Attachment { public const ALLOWED_ELEMENT_CLASS = Project::class; /** * @var Project|null the element this attachment is associated with - * @ORM\ManyToOne(targetEntity="App\Entity\ProjectSystem\Project", inversedBy="attachments") - * @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE"). */ + #[ORM\ManyToOne(targetEntity: 'App\Entity\ProjectSystem\Project', inversedBy: 'attachments')] + #[ORM\JoinColumn(name: 'element_id', nullable: false, onDelete: 'CASCADE')] protected ?AttachmentContainingDBElement $element = null; } diff --git a/src/Entity/Attachments/StorelocationAttachment.php b/src/Entity/Attachments/StorelocationAttachment.php index 95e0136d..b0fc6cb6 100644 --- a/src/Entity/Attachments/StorelocationAttachment.php +++ b/src/Entity/Attachments/StorelocationAttachment.php @@ -28,18 +28,17 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; /** * An attachment attached to a measurement unit element. - * - * @ORM\Entity() */ #[UniqueEntity(['name', 'attachment_type', 'element'])] +#[ORM\Entity] class StorelocationAttachment extends Attachment { public const ALLOWED_ELEMENT_CLASS = Storelocation::class; /** * @var Storelocation|null the element this attachment is associated with - * @ORM\ManyToOne(targetEntity="App\Entity\Parts\Storelocation", inversedBy="attachments") - * @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE"). */ + #[ORM\ManyToOne(targetEntity: 'App\Entity\Parts\Storelocation', inversedBy: 'attachments')] + #[ORM\JoinColumn(name: 'element_id', nullable: false, onDelete: 'CASCADE')] protected ?AttachmentContainingDBElement $element = null; } diff --git a/src/Entity/Attachments/SupplierAttachment.php b/src/Entity/Attachments/SupplierAttachment.php index fffa2e5b..0f611d4c 100644 --- a/src/Entity/Attachments/SupplierAttachment.php +++ b/src/Entity/Attachments/SupplierAttachment.php @@ -28,18 +28,17 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; /** * A attachment attached to a supplier element. - * - * @ORM\Entity() */ #[UniqueEntity(['name', 'attachment_type', 'element'])] +#[ORM\Entity] class SupplierAttachment extends Attachment { public const ALLOWED_ELEMENT_CLASS = Supplier::class; /** * @var Supplier|null the element this attachment is associated with - * @ORM\ManyToOne(targetEntity="App\Entity\Parts\Supplier", inversedBy="attachments") - * @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE"). */ + #[ORM\ManyToOne(targetEntity: 'App\Entity\Parts\Supplier', inversedBy: 'attachments')] + #[ORM\JoinColumn(name: 'element_id', nullable: false, onDelete: 'CASCADE')] protected ?AttachmentContainingDBElement $element = null; } diff --git a/src/Entity/Attachments/UserAttachment.php b/src/Entity/Attachments/UserAttachment.php index 67998d8e..8fc9b9df 100644 --- a/src/Entity/Attachments/UserAttachment.php +++ b/src/Entity/Attachments/UserAttachment.php @@ -28,18 +28,17 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; /** * An attachment attached to a user element. - * - * @ORM\Entity() */ #[UniqueEntity(['name', 'attachment_type', 'element'])] +#[ORM\Entity] class UserAttachment extends Attachment { public const ALLOWED_ELEMENT_CLASS = User::class; /** * @var User|null the element this attachment is associated with - * @ORM\ManyToOne(targetEntity="App\Entity\UserSystem\User", inversedBy="attachments") - * @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE"). */ + #[ORM\ManyToOne(targetEntity: 'App\Entity\UserSystem\User', inversedBy: 'attachments')] + #[ORM\JoinColumn(name: 'element_id', nullable: false, onDelete: 'CASCADE')] protected ?AttachmentContainingDBElement $element = null; } diff --git a/src/Entity/Base/AbstractCompany.php b/src/Entity/Base/AbstractCompany.php index 87acface..f265349a 100644 --- a/src/Entity/Base/AbstractCompany.php +++ b/src/Entity/Base/AbstractCompany.php @@ -29,52 +29,51 @@ use Symfony\Component\Validator\Constraints as Assert; /** * This abstract class is used for companies like suppliers or manufacturers. - * - * @ORM\MappedSuperclass() */ +#[ORM\MappedSuperclass] abstract class AbstractCompany extends AbstractPartsContainingDBElement { /** * @var string The address of the company - * @ORM\Column(type="string") */ #[Groups(['full'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING)] protected string $address = ''; /** * @var string The phone number of the company - * @ORM\Column(type="string") */ #[Groups(['full'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING)] protected string $phone_number = ''; /** * @var string The fax number of the company - * @ORM\Column(type="string") */ #[Groups(['full'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING)] protected string $fax_number = ''; /** * @var string The email address of the company - * @ORM\Column(type="string") */ #[Assert\Email] #[Groups(['full'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING)] protected string $email_address = ''; /** * @var string The website of the company - * @ORM\Column(type="string") */ #[Assert\Url] #[Groups(['full'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING)] protected string $website = ''; /** * @var string - * @ORM\Column(type="string") */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING)] protected string $auto_product_url = ''; /******************************************************************************** diff --git a/src/Entity/Base/AbstractDBElement.php b/src/Entity/Base/AbstractDBElement.php index e2946f4e..ce55c700 100644 --- a/src/Entity/Base/AbstractDBElement.php +++ b/src/Entity/Base/AbstractDBElement.php @@ -34,19 +34,18 @@ use Symfony\Component\Serializer\Annotation\Groups; * (except special tables like "internal"...) * Every database table which are managed with this class (or a subclass of it) * must have the table row "id"!! The ID is the unique key to identify the elements. - * - * @ORM\MappedSuperclass(repositoryClass="App\Repository\DBElementRepository") */ #[DiscriminatorMap(typeProperty: 'type', mapping: ['attachment_type' => 'App\Entity\Attachments\AttachmentType', 'attachment' => 'App\Entity\Attachments\Attachment', 'attachment_type_attachment' => 'App\Entity\Attachments\AttachmentTypeAttachment', 'category_attachment' => 'App\Entity\Attachments\CategoryAttachment', 'currency_attachment' => 'App\Entity\Attachments\CurrencyAttachment', 'footprint_attachment' => 'App\Entity\Attachments\FootprintAttachment', 'group_attachment' => 'App\Entity\Attachments\GroupAttachment', 'label_attachment' => 'App\Entity\Attachments\LabelAttachment', 'manufacturer_attachment' => 'App\Entity\Attachments\ManufacturerAttachment', 'measurement_unit_attachment' => 'App\Entity\Attachments\MeasurementUnitAttachment', 'part_attachment' => 'App\Entity\Attachments\PartAttachment', 'project_attachment' => 'App\Entity\Attachments\ProjectAttachment', 'storelocation_attachment' => 'App\Entity\Attachments\StorelocationAttachment', 'supplier_attachment' => 'App\Entity\Attachments\SupplierAttachment', 'user_attachment' => 'App\Entity\Attachments\UserAttachment', 'category' => 'App\Entity\Parts\Category', 'project' => 'App\Entity\ProjectSystem\Project', 'project_bom_entry' => 'App\Entity\ProjectSystem\ProjectBOMEntry', 'footprint' => 'App\Entity\Parts\Footprint', 'group' => 'App\Entity\UserSystem\Group', 'manufacturer' => 'App\Entity\Parts\Manufacturer', 'orderdetail' => 'App\Entity\PriceInformations\Orderdetail', 'part' => 'App\Entity\Parts\Part', 'pricedetail' => 'App\Entity\PriceInformation\Pricedetail', 'storelocation' => 'App\Entity\Parts\Storelocation', 'part_lot' => 'App\Entity\Parts\PartLot', 'currency' => 'App\Entity\PriceInformations\Currency', 'measurement_unit' => 'App\Entity\Parts\MeasurementUnit', 'parameter' => 'App\Entity\Parts\AbstractParameter', 'supplier' => 'App\Entity\Parts\Supplier', 'user' => 'App\Entity\UserSystem\User'])] +#[ORM\MappedSuperclass(repositoryClass: 'App\Repository\DBElementRepository')] abstract class AbstractDBElement implements JsonSerializable { /** @var int|null The Identification number for this part. This value is unique for the element in this table. * Null if the element is not saved to DB yet. - * @ORM\Column(type="integer") - * @ORM\Id() - * @ORM\GeneratedValue() */ #[Groups(['full'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER)] + #[ORM\Id] + #[ORM\GeneratedValue] protected ?int $id = null; public function __clone() diff --git a/src/Entity/Base/AbstractNamedDBElement.php b/src/Entity/Base/AbstractNamedDBElement.php index 90ebc91c..4b2b9d9e 100644 --- a/src/Entity/Base/AbstractNamedDBElement.php +++ b/src/Entity/Base/AbstractNamedDBElement.php @@ -30,20 +30,19 @@ use Symfony\Component\Validator\Constraints as Assert; /** * All subclasses of this class have an attribute "name". - * - * @ORM\MappedSuperclass(repositoryClass="App\Repository\NamedDBElement") - * @ORM\HasLifecycleCallbacks() */ +#[ORM\MappedSuperclass(repositoryClass: 'App\Repository\NamedDBElement')] +#[ORM\HasLifecycleCallbacks] abstract class AbstractNamedDBElement extends AbstractDBElement implements NamedElementInterface, TimeStampableInterface { use TimestampTrait; /** * @var string the name of this element - * @ORM\Column(type="string") */ #[Assert\NotBlank] #[Groups(['simple', 'extended', 'full', 'import'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING)] protected string $name = ''; /****************************************************************************** diff --git a/src/Entity/Base/AbstractPartsContainingDBElement.php b/src/Entity/Base/AbstractPartsContainingDBElement.php index a4a047ef..7ccb74c3 100644 --- a/src/Entity/Base/AbstractPartsContainingDBElement.php +++ b/src/Entity/Base/AbstractPartsContainingDBElement.php @@ -28,9 +28,8 @@ use Symfony\Component\Serializer\Annotation\Groups; /** * Class PartsContainingDBElement. - * - * @ORM\MappedSuperclass(repositoryClass="App\Repository\AbstractPartsContainingRepository") */ +#[ORM\MappedSuperclass(repositoryClass: 'App\Repository\AbstractPartsContainingRepository')] abstract class AbstractPartsContainingDBElement extends AbstractStructuralDBElement { #[Groups(['full'])] diff --git a/src/Entity/Base/AbstractStructuralDBElement.php b/src/Entity/Base/AbstractStructuralDBElement.php index 8ce54f0e..484fbaf6 100644 --- a/src/Entity/Base/AbstractStructuralDBElement.php +++ b/src/Entity/Base/AbstractStructuralDBElement.php @@ -43,11 +43,11 @@ use Symfony\Component\Serializer\Annotation\Groups; * It's allowed to have instances of root elements, but if you try to change * an attribute of a root element, you will get an exception! * - * @ORM\MappedSuperclass(repositoryClass="App\Repository\StructuralDBElementRepository") * - * @ORM\EntityListeners({"App\EntityListeners\TreeCacheInvalidationListener"}) */ #[UniqueEntity(fields: ['name', 'parent'], ignoreNull: false, message: 'structural.entity.unique_name')] +#[ORM\MappedSuperclass(repositoryClass: 'App\Repository\StructuralDBElementRepository')] +#[ORM\EntityListeners(['App\EntityListeners\TreeCacheInvalidationListener'])] abstract class AbstractStructuralDBElement extends AttachmentContainingDBElement { use ParametersTrait; @@ -61,17 +61,17 @@ abstract class AbstractStructuralDBElement extends AttachmentContainingDBElement /** * @var string The comment info for this element - * @ORM\Column(type="text") */ #[Groups(['full', 'import'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT)] protected string $comment = ''; /** * @var bool If this property is set, this element can not be selected for part properties. * Useful if this element should be used only for grouping, sorting. - * @ORM\Column(type="boolean") */ #[Groups(['full', 'import'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN)] protected bool $not_selectable = false; /** diff --git a/src/Entity/Base/MasterAttachmentTrait.php b/src/Entity/Base/MasterAttachmentTrait.php index b5e0f29a..f1451e1c 100644 --- a/src/Entity/Base/MasterAttachmentTrait.php +++ b/src/Entity/Base/MasterAttachmentTrait.php @@ -33,10 +33,10 @@ trait MasterAttachmentTrait { /** * @var Attachment|null - * @ORM\ManyToOne(targetEntity="App\Entity\Attachments\Attachment") - * @ORM\JoinColumn(name="id_preview_attachment", referencedColumnName="id", onDelete="SET NULL", nullable=true) */ #[Assert\Expression('value == null or value.isPicture()', message: 'part.master_attachment.must_be_picture')] + #[ORM\ManyToOne(targetEntity: 'App\Entity\Attachments\Attachment')] + #[ORM\JoinColumn(name: 'id_preview_attachment', onDelete: 'SET NULL')] protected ?Attachment $master_picture_attachment = null; /** diff --git a/src/Entity/LabelSystem/LabelOptions.php b/src/Entity/LabelSystem/LabelOptions.php index 913aa5b3..19360fb8 100644 --- a/src/Entity/LabelSystem/LabelOptions.php +++ b/src/Entity/LabelSystem/LabelOptions.php @@ -44,9 +44,7 @@ namespace App\Entity\LabelSystem; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Validator\Constraints as Assert; -/** - * @ORM\Embeddable() - */ +#[ORM\Embeddable] class LabelOptions { public const BARCODE_TYPES = ['none', /*'ean8',*/ 'qr', 'code39', 'datamatrix', 'code93', 'code128']; @@ -57,55 +55,55 @@ class LabelOptions /** * @var float The page size of the label in mm - * @ORM\Column(type="float") */ #[Assert\Positive] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::FLOAT)] protected float $width = 50.0; /** * @var float The page size of the label in mm - * @ORM\Column(type="float") */ #[Assert\Positive] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::FLOAT)] protected float $height = 30.0; /** * @var string The type of the barcode that should be used in the label (e.g. 'qr') - * @ORM\Column(type="string") */ #[Assert\Choice(choices: LabelOptions::BARCODE_TYPES)] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING)] protected string $barcode_type = 'none'; /** * @var string What image should be shown along the - * @ORM\Column(type="string") */ #[Assert\Choice(choices: LabelOptions::PICTURE_TYPES)] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING)] protected string $picture_type = 'none'; /** * @var string - * @ORM\Column(type="string") */ #[Assert\Choice(choices: LabelOptions::SUPPORTED_ELEMENTS)] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING)] protected string $supported_element = 'part'; /** * @var string any additional CSS for the label - * @ORM\Column(type="text") */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT)] protected string $additional_css = ''; /** @var string The mode that will be used to interpret the lines - * @ORM\Column(type="string") */ #[Assert\Choice(choices: LabelOptions::LINES_MODES)] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING)] protected string $lines_mode = 'html'; /** * @var string - * @ORM\Column(type="text") */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT)] protected string $lines = ''; public function getWidth(): float diff --git a/src/Entity/LabelSystem/LabelProfile.php b/src/Entity/LabelSystem/LabelProfile.php index ccd4087b..8548104b 100644 --- a/src/Entity/LabelSystem/LabelProfile.php +++ b/src/Entity/LabelSystem/LabelProfile.php @@ -48,42 +48,41 @@ use Doctrine\ORM\Mapping as ORM; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; use Symfony\Component\Validator\Constraints as Assert; -/** - * @ORM\Entity(repositoryClass="App\Repository\LabelProfileRepository") - * @ORM\Table(name="label_profiles") - * @ORM\EntityListeners({"App\EntityListeners\TreeCacheInvalidationListener"}) - */ #[UniqueEntity(['name', 'options.supported_element'])] +#[ORM\Entity(repositoryClass: 'App\Repository\LabelProfileRepository')] +#[ORM\EntityListeners(['App\EntityListeners\TreeCacheInvalidationListener'])] +#[ORM\Table(name: 'label_profiles')] class LabelProfile extends AttachmentContainingDBElement { /** * @var Collection - * @ORM\OneToMany(targetEntity="App\Entity\Attachments\LabelAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true) - * @ORM\OrderBy({"name" = "ASC"}) */ + #[ORM\OneToMany(targetEntity: 'App\Entity\Attachments\LabelAttachment', mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)] + #[ORM\OrderBy(['name' => 'ASC'])] protected Collection $attachments; /** * @var LabelOptions - * @ORM\Embedded(class="LabelOptions") */ #[Assert\Valid] + #[ORM\Embedded(class: 'LabelOptions')] protected LabelOptions $options; /** * @var string The comment info for this element - * @ORM\Column(type="text") */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT)] protected string $comment = ''; /** * @var bool determines, if this label profile should be shown in the dropdown quick menu - * @ORM\Column(type="boolean") */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN)] protected bool $show_in_dropdown = true; public function __construct() { + $this->attachments = new \Doctrine\Common\Collections\ArrayCollection(); parent::__construct(); $this->options = new LabelOptions(); } diff --git a/src/Entity/LogSystem/CollectionElementDeleted.php b/src/Entity/LogSystem/CollectionElementDeleted.php index 9e646cca..15f23e7f 100644 --- a/src/Entity/LogSystem/CollectionElementDeleted.php +++ b/src/Entity/LogSystem/CollectionElementDeleted.php @@ -84,11 +84,7 @@ use App\Entity\UserSystem\User; use Doctrine\ORM\Mapping as ORM; use InvalidArgumentException; -/** - * @ORM\Entity() - * This log entry is created when an element is deleted, that is used in a collection of another entity. - * This is needed to signal time travel, that it has to undelete the deleted entity. - */ +#[ORM\Entity] class CollectionElementDeleted extends AbstractLogEntry implements LogWithEventUndoInterface { protected string $typeString = 'collection_element_deleted'; diff --git a/src/Entity/LogSystem/ConfigChangedLogEntry.php b/src/Entity/LogSystem/ConfigChangedLogEntry.php index 543886bf..68f8edf3 100644 --- a/src/Entity/LogSystem/ConfigChangedLogEntry.php +++ b/src/Entity/LogSystem/ConfigChangedLogEntry.php @@ -25,9 +25,7 @@ namespace App\Entity\LogSystem; use App\Exceptions\LogEntryObsoleteException; use Doctrine\ORM\Mapping as ORM; -/** - * @ORM\Entity() - */ +#[ORM\Entity] class ConfigChangedLogEntry extends AbstractLogEntry { protected string $typeString = 'config_changed'; diff --git a/src/Entity/LogSystem/DatabaseUpdatedLogEntry.php b/src/Entity/LogSystem/DatabaseUpdatedLogEntry.php index 0f85ba11..6e137373 100644 --- a/src/Entity/LogSystem/DatabaseUpdatedLogEntry.php +++ b/src/Entity/LogSystem/DatabaseUpdatedLogEntry.php @@ -24,9 +24,7 @@ namespace App\Entity\LogSystem; use Doctrine\ORM\Mapping as ORM; -/** - * @ORM\Entity() - */ +#[ORM\Entity] class DatabaseUpdatedLogEntry extends AbstractLogEntry { protected string $typeString = 'database_updated'; diff --git a/src/Entity/LogSystem/ElementCreatedLogEntry.php b/src/Entity/LogSystem/ElementCreatedLogEntry.php index c78e6df0..9cac58b3 100644 --- a/src/Entity/LogSystem/ElementCreatedLogEntry.php +++ b/src/Entity/LogSystem/ElementCreatedLogEntry.php @@ -30,9 +30,7 @@ use App\Entity\UserSystem\User; use Doctrine\ORM\Mapping as ORM; use InvalidArgumentException; -/** - * @ORM\Entity() - */ +#[ORM\Entity] class ElementCreatedLogEntry extends AbstractLogEntry implements LogWithCommentInterface, LogWithEventUndoInterface { protected string $typeString = 'element_created'; diff --git a/src/Entity/LogSystem/ElementDeletedLogEntry.php b/src/Entity/LogSystem/ElementDeletedLogEntry.php index c20bf87c..29ab6a91 100644 --- a/src/Entity/LogSystem/ElementDeletedLogEntry.php +++ b/src/Entity/LogSystem/ElementDeletedLogEntry.php @@ -32,9 +32,7 @@ use App\Entity\UserSystem\User; use Doctrine\ORM\Mapping as ORM; use InvalidArgumentException; -/** - * @ORM\Entity() - */ +#[ORM\Entity] class ElementDeletedLogEntry extends AbstractLogEntry implements TimeTravelInterface, LogWithCommentInterface, LogWithEventUndoInterface { protected string $typeString = 'element_deleted'; diff --git a/src/Entity/LogSystem/ElementEditedLogEntry.php b/src/Entity/LogSystem/ElementEditedLogEntry.php index fb5f2e5c..dab87652 100644 --- a/src/Entity/LogSystem/ElementEditedLogEntry.php +++ b/src/Entity/LogSystem/ElementEditedLogEntry.php @@ -30,9 +30,7 @@ use App\Entity\Contracts\TimeTravelInterface; use Doctrine\ORM\Mapping as ORM; use InvalidArgumentException; -/** - * @ORM\Entity() - */ +#[ORM\Entity] class ElementEditedLogEntry extends AbstractLogEntry implements TimeTravelInterface, LogWithCommentInterface, LogWithEventUndoInterface, LogWithNewDataInterface { protected string $typeString = 'element_edited'; diff --git a/src/Entity/LogSystem/ExceptionLogEntry.php b/src/Entity/LogSystem/ExceptionLogEntry.php index dc9a7f32..e8fb06f9 100644 --- a/src/Entity/LogSystem/ExceptionLogEntry.php +++ b/src/Entity/LogSystem/ExceptionLogEntry.php @@ -25,9 +25,7 @@ namespace App\Entity\LogSystem; use App\Exceptions\LogEntryObsoleteException; use Doctrine\ORM\Mapping as ORM; -/** - * @ORM\Entity() - */ +#[ORM\Entity] class ExceptionLogEntry extends AbstractLogEntry { protected string $typeString = 'exception'; diff --git a/src/Entity/LogSystem/LegacyInstockChangedLogEntry.php b/src/Entity/LogSystem/LegacyInstockChangedLogEntry.php index 9af3dd69..27f7afe4 100644 --- a/src/Entity/LogSystem/LegacyInstockChangedLogEntry.php +++ b/src/Entity/LogSystem/LegacyInstockChangedLogEntry.php @@ -24,9 +24,7 @@ namespace App\Entity\LogSystem; use Doctrine\ORM\Mapping as ORM; -/** - * @ORM\Entity() - */ +#[ORM\Entity] class LegacyInstockChangedLogEntry extends AbstractLogEntry { protected string $typeString = 'instock_changed'; diff --git a/src/Entity/LogSystem/PartStockChangedLogEntry.php b/src/Entity/LogSystem/PartStockChangedLogEntry.php index 44852076..5fc755bf 100644 --- a/src/Entity/LogSystem/PartStockChangedLogEntry.php +++ b/src/Entity/LogSystem/PartStockChangedLogEntry.php @@ -23,9 +23,7 @@ namespace App\Entity\LogSystem; use App\Entity\Parts\PartLot; use Doctrine\ORM\Mapping as ORM; -/** - * @ORM\Entity() - */ +#[ORM\Entity] class PartStockChangedLogEntry extends AbstractLogEntry { public const TYPE_ADD = "add"; diff --git a/src/Entity/LogSystem/SecurityEventLogEntry.php b/src/Entity/LogSystem/SecurityEventLogEntry.php index 2113beb9..2d74f5ea 100644 --- a/src/Entity/LogSystem/SecurityEventLogEntry.php +++ b/src/Entity/LogSystem/SecurityEventLogEntry.php @@ -50,9 +50,8 @@ use Symfony\Component\HttpFoundation\IpUtils; /** * This log entry is created when something security related to a user happens. - * - * @ORM\Entity() */ +#[ORM\Entity] class SecurityEventLogEntry extends AbstractLogEntry { public const SECURITY_TYPE_MAPPING = [ diff --git a/src/Entity/LogSystem/UserLoginLogEntry.php b/src/Entity/LogSystem/UserLoginLogEntry.php index d1acaa6e..166533c4 100644 --- a/src/Entity/LogSystem/UserLoginLogEntry.php +++ b/src/Entity/LogSystem/UserLoginLogEntry.php @@ -27,9 +27,8 @@ use Symfony\Component\HttpFoundation\IpUtils; /** * This log entry is created when a user logs in. - * - * @ORM\Entity() */ +#[ORM\Entity] class UserLoginLogEntry extends AbstractLogEntry { protected string $typeString = 'user_login'; diff --git a/src/Entity/LogSystem/UserLogoutLogEntry.php b/src/Entity/LogSystem/UserLogoutLogEntry.php index 43a98fb6..9fce3069 100644 --- a/src/Entity/LogSystem/UserLogoutLogEntry.php +++ b/src/Entity/LogSystem/UserLogoutLogEntry.php @@ -25,9 +25,7 @@ namespace App\Entity\LogSystem; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\HttpFoundation\IpUtils; -/** - * @ORM\Entity() - */ +#[ORM\Entity] class UserLogoutLogEntry extends AbstractLogEntry { protected string $typeString = 'user_logout'; diff --git a/src/Entity/LogSystem/UserNotAllowedLogEntry.php b/src/Entity/LogSystem/UserNotAllowedLogEntry.php index 5d4e3acd..99fb2492 100644 --- a/src/Entity/LogSystem/UserNotAllowedLogEntry.php +++ b/src/Entity/LogSystem/UserNotAllowedLogEntry.php @@ -24,9 +24,7 @@ namespace App\Entity\LogSystem; use Doctrine\ORM\Mapping as ORM; -/** - * @ORM\Entity() - */ +#[ORM\Entity] class UserNotAllowedLogEntry extends AbstractLogEntry { protected string $typeString = 'user_not_allowed'; diff --git a/src/Entity/Parameters/AbstractParameter.php b/src/Entity/Parameters/AbstractParameter.php index 134d44aa..b033c0ac 100644 --- a/src/Entity/Parameters/AbstractParameter.php +++ b/src/Entity/Parameters/AbstractParameter.php @@ -51,29 +51,14 @@ use Symfony\Component\Validator\Constraints as Assert; use function sprintf; -/** - * @ORM\Entity(repositoryClass="App\Repository\ParameterRepository") - * @ORM\Table("parameters", indexes={ - * @ORM\Index(name="parameter_name_idx", columns={"name"}), - * @ORM\Index(name="parameter_group_idx", columns={"param_group"}), - * @ORM\Index(name="parameter_type_element_idx", columns={"type", "element_id"}) - * }) - * @ORM\InheritanceType("SINGLE_TABLE") - * @ORM\DiscriminatorColumn(name="type", type="smallint") - * @ORM\DiscriminatorMap({ - * 0 = "CategoryParameter", - * 1 = "CurrencyParameter", - * 2 = "ProjectParameter", - * 3 = "FootprintParameter", - * 4 = "GroupParameter", - * 5 = "ManufacturerParameter", - * 6 = "MeasurementUnitParameter", - * 7 = "PartParameter", - * 8 = "StorelocationParameter", - * 9 = "SupplierParameter", - * 10 = "AttachmentTypeParameter" - * }) - */ +#[ORM\Entity(repositoryClass: 'App\Repository\ParameterRepository')] +#[ORM\InheritanceType('SINGLE_TABLE')] +#[ORM\DiscriminatorColumn(name: 'type', type: 'smallint')] +#[ORM\DiscriminatorMap([0 => 'CategoryParameter', 1 => 'CurrencyParameter', 2 => 'ProjectParameter', 3 => 'FootprintParameter', 4 => 'GroupParameter', 5 => 'ManufacturerParameter', 6 => 'MeasurementUnitParameter', 7 => 'PartParameter', 8 => 'StorelocationParameter', 9 => 'SupplierParameter', 10 => 'AttachmentTypeParameter'])] +#[ORM\Table('parameters')] +#[ORM\Index(name: 'parameter_name_idx', columns: ['name'])] +#[ORM\Index(name: 'parameter_group_idx', columns: ['param_group'])] +#[ORM\Index(name: 'parameter_type_element_idx', columns: ['type', 'element_id'])] abstract class AbstractParameter extends AbstractNamedDBElement { /** @@ -83,59 +68,59 @@ abstract class AbstractParameter extends AbstractNamedDBElement /** * @var string The mathematical symbol for this specification. Can be rendered pretty later. Should be short - * @ORM\Column(type="string", nullable=false) */ #[Assert\Length(max: 20)] #[Groups(['full'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING)] protected string $symbol = ''; /** * @var float|null the guaranteed minimum value of this property - * @ORM\Column(type="float", nullable=true) */ #[Assert\Type(['float', null])] #[Assert\LessThanOrEqual(propertyPath: 'value_typical', message: 'parameters.validator.min_lesser_typical')] #[Assert\LessThan(propertyPath: 'value_max', message: 'parameters.validator.min_lesser_max')] #[Groups(['full'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::FLOAT, nullable: true)] protected ?float $value_min = null; /** * @var float|null the typical value of this property - * @ORM\Column(type="float", nullable=true) */ #[Assert\Type([null, 'float'])] #[Groups(['full'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::FLOAT, nullable: true)] protected ?float $value_typical = null; /** * @var float|null the maximum value of this property - * @ORM\Column(type="float", nullable=true) */ #[Assert\Type(['float', null])] #[Assert\GreaterThanOrEqual(propertyPath: 'value_typical', message: 'parameters.validator.max_greater_typical')] #[Groups(['full'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::FLOAT, nullable: true)] protected ?float $value_max = null; /** * @var string The unit in which the value values are given (e.g. V) - * @ORM\Column(type="string", nullable=false) */ #[Groups(['full'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING)] protected string $unit = ''; /** * @var string a text value for the given property - * @ORM\Column(type="string", nullable=false) */ #[Groups(['full'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING)] protected string $value_text = ''; /** * @var string the group this parameter belongs to - * @ORM\Column(type="string", nullable=false, name="param_group") */ #[Groups(['full'])] #[Groups(['full'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, name: 'param_group')] protected string $group = ''; /** diff --git a/src/Entity/Parameters/AttachmentTypeParameter.php b/src/Entity/Parameters/AttachmentTypeParameter.php index 12b05ae7..28f53669 100644 --- a/src/Entity/Parameters/AttachmentTypeParameter.php +++ b/src/Entity/Parameters/AttachmentTypeParameter.php @@ -46,17 +46,15 @@ use App\Entity\Base\AbstractDBElement; use Doctrine\ORM\Mapping as ORM; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; -/** - * @ORM\Entity(repositoryClass="App\Repository\ParameterRepository") - */ #[UniqueEntity(fields: ['name', 'group', 'element'])] +#[ORM\Entity(repositoryClass: 'App\Repository\ParameterRepository')] class AttachmentTypeParameter extends AbstractParameter { public const ALLOWED_ELEMENT_CLASS = AttachmentType::class; /** * @var AttachmentType the element this para is associated with - * @ORM\ManyToOne(targetEntity="App\Entity\Attachments\AttachmentType", inversedBy="parameters") - * @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE"). */ + #[ORM\ManyToOne(targetEntity: 'App\Entity\Attachments\AttachmentType', inversedBy: 'parameters')] + #[ORM\JoinColumn(name: 'element_id', nullable: false, onDelete: 'CASCADE')] protected ?AbstractDBElement $element = null; } diff --git a/src/Entity/Parameters/CategoryParameter.php b/src/Entity/Parameters/CategoryParameter.php index c80004a0..ba71e46f 100644 --- a/src/Entity/Parameters/CategoryParameter.php +++ b/src/Entity/Parameters/CategoryParameter.php @@ -46,17 +46,15 @@ use App\Entity\Parts\Category; use Doctrine\ORM\Mapping as ORM; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; -/** - * @ORM\Entity(repositoryClass="App\Repository\ParameterRepository") - */ #[UniqueEntity(fields: ['name', 'group', 'element'])] +#[ORM\Entity(repositoryClass: 'App\Repository\ParameterRepository')] class CategoryParameter extends AbstractParameter { public const ALLOWED_ELEMENT_CLASS = Category::class; /** * @var Category the element this para is associated with - * @ORM\ManyToOne(targetEntity="App\Entity\Parts\Category", inversedBy="parameters") - * @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE"). */ + #[ORM\ManyToOne(targetEntity: 'App\Entity\Parts\Category', inversedBy: 'parameters')] + #[ORM\JoinColumn(name: 'element_id', nullable: false, onDelete: 'CASCADE')] protected ?AbstractDBElement $element = null; } diff --git a/src/Entity/Parameters/CurrencyParameter.php b/src/Entity/Parameters/CurrencyParameter.php index a9f1133e..fc3d6726 100644 --- a/src/Entity/Parameters/CurrencyParameter.php +++ b/src/Entity/Parameters/CurrencyParameter.php @@ -48,18 +48,17 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; /** * An attachment attached to a category element. - * - * @ORM\Entity(repositoryClass="App\Repository\ParameterRepository") */ #[UniqueEntity(fields: ['name', 'group', 'element'])] +#[ORM\Entity(repositoryClass: 'App\Repository\ParameterRepository')] class CurrencyParameter extends AbstractParameter { public const ALLOWED_ELEMENT_CLASS = Currency::class; /** * @var Currency the element this para is associated with - * @ORM\ManyToOne(targetEntity="App\Entity\PriceInformations\Currency", inversedBy="parameters") - * @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE"). */ + #[ORM\ManyToOne(targetEntity: 'App\Entity\PriceInformations\Currency', inversedBy: 'parameters')] + #[ORM\JoinColumn(name: 'element_id', nullable: false, onDelete: 'CASCADE')] protected ?AbstractDBElement $element = null; } diff --git a/src/Entity/Parameters/FootprintParameter.php b/src/Entity/Parameters/FootprintParameter.php index be65d737..1f8f517b 100644 --- a/src/Entity/Parameters/FootprintParameter.php +++ b/src/Entity/Parameters/FootprintParameter.php @@ -46,18 +46,16 @@ use App\Entity\Parts\Footprint; use Doctrine\ORM\Mapping as ORM; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; -/** - * @ORM\Entity(repositoryClass="App\Repository\ParameterRepository") - */ #[UniqueEntity(fields: ['name', 'group', 'element'])] +#[ORM\Entity(repositoryClass: 'App\Repository\ParameterRepository')] class FootprintParameter extends AbstractParameter { public const ALLOWED_ELEMENT_CLASS = Footprint::class; /** * @var Footprint the element this para is associated with - * @ORM\ManyToOne(targetEntity="App\Entity\Parts\Footprint", inversedBy="parameters") - * @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE"). */ + #[ORM\ManyToOne(targetEntity: 'App\Entity\Parts\Footprint', inversedBy: 'parameters')] + #[ORM\JoinColumn(name: 'element_id', nullable: false, onDelete: 'CASCADE')] protected ?AbstractDBElement $element = null; } diff --git a/src/Entity/Parameters/GroupParameter.php b/src/Entity/Parameters/GroupParameter.php index c283e142..0b181929 100644 --- a/src/Entity/Parameters/GroupParameter.php +++ b/src/Entity/Parameters/GroupParameter.php @@ -46,18 +46,16 @@ use App\Entity\UserSystem\Group; use Doctrine\ORM\Mapping as ORM; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; -/** - * @ORM\Entity(repositoryClass="App\Repository\ParameterRepository") - */ #[UniqueEntity(fields: ['name', 'group', 'element'])] +#[ORM\Entity(repositoryClass: 'App\Repository\ParameterRepository')] class GroupParameter extends AbstractParameter { public const ALLOWED_ELEMENT_CLASS = Group::class; /** * @var Group the element this para is associated with - * @ORM\ManyToOne(targetEntity="App\Entity\UserSystem\Group", inversedBy="parameters") - * @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE"). */ + #[ORM\ManyToOne(targetEntity: 'App\Entity\UserSystem\Group', inversedBy: 'parameters')] + #[ORM\JoinColumn(name: 'element_id', nullable: false, onDelete: 'CASCADE')] protected ?AbstractDBElement $element = null; } diff --git a/src/Entity/Parameters/ManufacturerParameter.php b/src/Entity/Parameters/ManufacturerParameter.php index fd990dd2..3fa585cf 100644 --- a/src/Entity/Parameters/ManufacturerParameter.php +++ b/src/Entity/Parameters/ManufacturerParameter.php @@ -46,18 +46,16 @@ use App\Entity\Parts\Manufacturer; use Doctrine\ORM\Mapping as ORM; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; -/** - * @ORM\Entity(repositoryClass="App\Repository\ParameterRepository") - */ #[UniqueEntity(fields: ['name', 'group', 'element'])] +#[ORM\Entity(repositoryClass: 'App\Repository\ParameterRepository')] class ManufacturerParameter extends AbstractParameter { public const ALLOWED_ELEMENT_CLASS = Manufacturer::class; /** * @var Manufacturer the element this para is associated with - * @ORM\ManyToOne(targetEntity="App\Entity\Parts\Manufacturer", inversedBy="parameters") - * @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE"). */ + #[ORM\ManyToOne(targetEntity: 'App\Entity\Parts\Manufacturer', inversedBy: 'parameters')] + #[ORM\JoinColumn(name: 'element_id', nullable: false, onDelete: 'CASCADE')] protected ?AbstractDBElement $element = null; } diff --git a/src/Entity/Parameters/MeasurementUnitParameter.php b/src/Entity/Parameters/MeasurementUnitParameter.php index 2dbc94f8..67d20f3f 100644 --- a/src/Entity/Parameters/MeasurementUnitParameter.php +++ b/src/Entity/Parameters/MeasurementUnitParameter.php @@ -46,18 +46,16 @@ use App\Entity\Parts\MeasurementUnit; use Doctrine\ORM\Mapping as ORM; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; -/** - * @ORM\Entity(repositoryClass="App\Repository\ParameterRepository") - */ #[UniqueEntity(fields: ['name', 'group', 'element'])] +#[ORM\Entity(repositoryClass: 'App\Repository\ParameterRepository')] class MeasurementUnitParameter extends AbstractParameter { public const ALLOWED_ELEMENT_CLASS = MeasurementUnit::class; /** * @var MeasurementUnit the element this para is associated with - * @ORM\ManyToOne(targetEntity="App\Entity\Parts\MeasurementUnit", inversedBy="parameters") - * @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE"). */ + #[ORM\ManyToOne(targetEntity: 'App\Entity\Parts\MeasurementUnit', inversedBy: 'parameters')] + #[ORM\JoinColumn(name: 'element_id', nullable: false, onDelete: 'CASCADE')] protected ?AbstractDBElement $element = null; } diff --git a/src/Entity/Parameters/PartParameter.php b/src/Entity/Parameters/PartParameter.php index 11798919..97494abc 100644 --- a/src/Entity/Parameters/PartParameter.php +++ b/src/Entity/Parameters/PartParameter.php @@ -46,18 +46,16 @@ use App\Entity\Parts\Part; use Doctrine\ORM\Mapping as ORM; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; -/** - * @ORM\Entity(repositoryClass="App\Repository\ParameterRepository") - */ #[UniqueEntity(fields: ['name', 'group', 'element'])] +#[ORM\Entity(repositoryClass: 'App\Repository\ParameterRepository')] class PartParameter extends AbstractParameter { public const ALLOWED_ELEMENT_CLASS = Part::class; /** * @var Part the element this para is associated with - * @ORM\ManyToOne(targetEntity="App\Entity\Parts\Part", inversedBy="parameters") - * @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE"). */ + #[ORM\ManyToOne(targetEntity: 'App\Entity\Parts\Part', inversedBy: 'parameters')] + #[ORM\JoinColumn(name: 'element_id', nullable: false, onDelete: 'CASCADE')] protected ?AbstractDBElement $element = null; } diff --git a/src/Entity/Parameters/ProjectParameter.php b/src/Entity/Parameters/ProjectParameter.php index 362cde04..bda1b59a 100644 --- a/src/Entity/Parameters/ProjectParameter.php +++ b/src/Entity/Parameters/ProjectParameter.php @@ -46,18 +46,16 @@ use App\Entity\ProjectSystem\Project; use Doctrine\ORM\Mapping as ORM; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; -/** - * @ORM\Entity(repositoryClass="App\Repository\ParameterRepository") - */ #[UniqueEntity(fields: ['name', 'group', 'element'])] +#[ORM\Entity(repositoryClass: 'App\Repository\ParameterRepository')] class ProjectParameter extends AbstractParameter { public const ALLOWED_ELEMENT_CLASS = Project::class; /** * @var Project the element this para is associated with - * @ORM\ManyToOne(targetEntity="App\Entity\ProjectSystem\Project", inversedBy="parameters") - * @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE"). */ + #[ORM\ManyToOne(targetEntity: 'App\Entity\ProjectSystem\Project', inversedBy: 'parameters')] + #[ORM\JoinColumn(name: 'element_id', nullable: false, onDelete: 'CASCADE')] protected ?AbstractDBElement $element = null; } diff --git a/src/Entity/Parameters/StorelocationParameter.php b/src/Entity/Parameters/StorelocationParameter.php index 6b792588..f119f4a7 100644 --- a/src/Entity/Parameters/StorelocationParameter.php +++ b/src/Entity/Parameters/StorelocationParameter.php @@ -46,18 +46,16 @@ use App\Entity\Parts\Storelocation; use Doctrine\ORM\Mapping as ORM; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; -/** - * @ORM\Entity(repositoryClass="App\Repository\ParameterRepository") - */ #[UniqueEntity(fields: ['name', 'group', 'element'])] +#[ORM\Entity(repositoryClass: 'App\Repository\ParameterRepository')] class StorelocationParameter extends AbstractParameter { public const ALLOWED_ELEMENT_CLASS = Storelocation::class; /** * @var Storelocation the element this para is associated with - * @ORM\ManyToOne(targetEntity="App\Entity\Parts\Storelocation", inversedBy="parameters") - * @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE"). */ + #[ORM\ManyToOne(targetEntity: 'App\Entity\Parts\Storelocation', inversedBy: 'parameters')] + #[ORM\JoinColumn(name: 'element_id', nullable: false, onDelete: 'CASCADE')] protected ?AbstractDBElement $element = null; } diff --git a/src/Entity/Parameters/SupplierParameter.php b/src/Entity/Parameters/SupplierParameter.php index 3281a722..e3087c27 100644 --- a/src/Entity/Parameters/SupplierParameter.php +++ b/src/Entity/Parameters/SupplierParameter.php @@ -46,18 +46,16 @@ use App\Entity\Parts\Supplier; use Doctrine\ORM\Mapping as ORM; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; -/** - * @ORM\Entity(repositoryClass="App\Repository\ParameterRepository") - */ #[UniqueEntity(fields: ['name', 'group', 'element'])] +#[ORM\Entity(repositoryClass: 'App\Repository\ParameterRepository')] class SupplierParameter extends AbstractParameter { public const ALLOWED_ELEMENT_CLASS = Supplier::class; /** * @var Supplier the element this para is associated with - * @ORM\ManyToOne(targetEntity="App\Entity\Parts\Supplier", inversedBy="parameters") - * @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE"). */ + #[ORM\ManyToOne(targetEntity: 'App\Entity\Parts\Supplier', inversedBy: 'parameters')] + #[ORM\JoinColumn(name: 'element_id', nullable: false, onDelete: 'CASCADE')] protected ?AbstractDBElement $element = null; } diff --git a/src/Entity/Parts/Category.php b/src/Entity/Parts/Category.php index 990a7a1e..56450f11 100644 --- a/src/Entity/Parts/Category.php +++ b/src/Entity/Parts/Category.php @@ -33,99 +33,95 @@ use Symfony\Component\Validator\Constraints as Assert; /** * Class AttachmentType. - * - * @ORM\Entity(repositoryClass="App\Repository\Parts\CategoryRepository") - * @ORM\Table(name="`categories`", indexes={ - * @ORM\Index(name="category_idx_name", columns={"name"}), - * @ORM\Index(name="category_idx_parent_name", columns={"parent_id", "name"}), - * }) */ +#[ORM\Entity(repositoryClass: 'App\Repository\Parts\CategoryRepository')] +#[ORM\Table(name: '`categories`')] +#[ORM\Index(name: 'category_idx_name', columns: ['name'])] +#[ORM\Index(name: 'category_idx_parent_name', columns: ['parent_id', 'name'])] class Category extends AbstractPartsContainingDBElement { /** - * @ORM\OneToMany(targetEntity="Category", mappedBy="parent") - * @ORM\OrderBy({"name" = "ASC"}) * @var Collection */ + #[ORM\OneToMany(targetEntity: 'Category', mappedBy: 'parent')] + #[ORM\OrderBy(['name' => 'ASC'])] protected Collection $children; - /** - * @ORM\ManyToOne(targetEntity="Category", inversedBy="children") - * @ORM\JoinColumn(name="parent_id", referencedColumnName="id") - */ + #[ORM\ManyToOne(targetEntity: 'Category', inversedBy: 'children')] + #[ORM\JoinColumn(name: 'parent_id')] protected ?AbstractStructuralDBElement $parent = null; /** * @var string - * @ORM\Column(type="text") */ #[Groups(['full', 'import'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT)] protected string $partname_hint = ''; /** * @var string - * @ORM\Column(type="text") */ #[Groups(['full', 'import'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT)] protected string $partname_regex = ''; /** * @var bool - * @ORM\Column(type="boolean") */ #[Groups(['full', 'import'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN)] protected bool $disable_footprints = false; /** * @var bool - * @ORM\Column(type="boolean") */ #[Groups(['full', 'import'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN)] protected bool $disable_manufacturers = false; /** * @var bool - * @ORM\Column(type="boolean") */ #[Groups(['full', 'import'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN)] protected bool $disable_autodatasheets = false; /** * @var bool - * @ORM\Column(type="boolean") */ #[Groups(['full', 'import'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN)] protected bool $disable_properties = false; /** * @var string - * @ORM\Column(type="text") */ #[Groups(['full', 'import'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT)] protected string $default_description = ''; /** * @var string - * @ORM\Column(type="text") */ #[Groups(['full', 'import'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT)] protected string $default_comment = ''; /** * @var Collection - * @ORM\OneToMany(targetEntity="App\Entity\Attachments\CategoryAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true) - * @ORM\OrderBy({"name" = "ASC"}) */ #[Assert\Valid] #[Groups(['full'])] + #[ORM\OneToMany(targetEntity: 'App\Entity\Attachments\CategoryAttachment', mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)] + #[ORM\OrderBy(['name' => 'ASC'])] protected Collection $attachments; /** @var Collection - * @ORM\OneToMany(targetEntity="App\Entity\Parameters\CategoryParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true) - * @ORM\OrderBy({"group" = "ASC" ,"name" = "ASC"}) */ #[Assert\Valid] #[Groups(['full'])] + #[ORM\OneToMany(targetEntity: 'App\Entity\Parameters\CategoryParameter', mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)] + #[ORM\OrderBy(['group' => 'ASC', 'name' => 'ASC'])] protected Collection $parameters; public function getPartnameHint(): string @@ -247,4 +243,11 @@ class Category extends AbstractPartsContainingDBElement return $this; } + public function __construct() + { + parent::__construct(); + $this->children = new \Doctrine\Common\Collections\ArrayCollection(); + $this->attachments = new \Doctrine\Common\Collections\ArrayCollection(); + $this->parameters = new \Doctrine\Common\Collections\ArrayCollection(); + } } diff --git a/src/Entity/Parts/Footprint.php b/src/Entity/Parts/Footprint.php index 2949d6a8..f7c56a79 100644 --- a/src/Entity/Parts/Footprint.php +++ b/src/Entity/Parts/Footprint.php @@ -31,48 +31,44 @@ use Symfony\Component\Validator\Constraints as Assert; /** * Class Footprint. - * - * @ORM\Entity(repositoryClass="App\Repository\Parts\FootprintRepository") - * @ORM\Table("`footprints`", indexes={ - * @ORM\Index(name="footprint_idx_name", columns={"name"}), - * @ORM\Index(name="footprint_idx_parent_name", columns={"parent_id", "name"}), - * }) */ +#[ORM\Entity(repositoryClass: 'App\Repository\Parts\FootprintRepository')] +#[ORM\Table('`footprints`')] +#[ORM\Index(name: 'footprint_idx_name', columns: ['name'])] +#[ORM\Index(name: 'footprint_idx_parent_name', columns: ['parent_id', 'name'])] class Footprint extends AbstractPartsContainingDBElement { - /** - * @ORM\ManyToOne(targetEntity="Footprint", inversedBy="children") - * @ORM\JoinColumn(name="parent_id", referencedColumnName="id") - */ + #[ORM\ManyToOne(targetEntity: 'Footprint', inversedBy: 'children')] + #[ORM\JoinColumn(name: 'parent_id')] protected ?\App\Entity\Base\AbstractStructuralDBElement $parent; /** - * @ORM\OneToMany(targetEntity="Footprint", mappedBy="parent") - * @ORM\OrderBy({"name" = "ASC"}) * @var Collection */ + #[ORM\OneToMany(targetEntity: 'Footprint', mappedBy: 'parent')] + #[ORM\OrderBy(['name' => 'ASC'])] protected Collection $children; /** * @var Collection - * @ORM\OneToMany(targetEntity="App\Entity\Attachments\FootprintAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true) - * @ORM\OrderBy({"name" = "ASC"}) */ #[Assert\Valid] + #[ORM\OneToMany(targetEntity: 'App\Entity\Attachments\FootprintAttachment', mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)] + #[ORM\OrderBy(['name' => 'ASC'])] protected Collection $attachments; /** * @var FootprintAttachment|null - * @ORM\ManyToOne(targetEntity="App\Entity\Attachments\FootprintAttachment") - * @ORM\JoinColumn(name="id_footprint_3d", referencedColumnName="id") */ + #[ORM\ManyToOne(targetEntity: 'App\Entity\Attachments\FootprintAttachment')] + #[ORM\JoinColumn(name: 'id_footprint_3d')] protected ?FootprintAttachment $footprint_3d = null; /** @var Collection - * @ORM\OneToMany(targetEntity="App\Entity\Parameters\FootprintParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true) - * @ORM\OrderBy({"group" = "ASC" ,"name" = "ASC"}) */ #[Assert\Valid] + #[ORM\OneToMany(targetEntity: 'App\Entity\Parameters\FootprintParameter', mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)] + #[ORM\OrderBy(['group' => 'ASC', 'name' => 'ASC'])] protected Collection $parameters; /**************************************** @@ -106,4 +102,11 @@ class Footprint extends AbstractPartsContainingDBElement return $this; } + public function __construct() + { + parent::__construct(); + $this->children = new \Doctrine\Common\Collections\ArrayCollection(); + $this->attachments = new \Doctrine\Common\Collections\ArrayCollection(); + $this->parameters = new \Doctrine\Common\Collections\ArrayCollection(); + } } diff --git a/src/Entity/Parts/Manufacturer.php b/src/Entity/Parts/Manufacturer.php index 7e8f75b1..1e56bcfb 100644 --- a/src/Entity/Parts/Manufacturer.php +++ b/src/Entity/Parts/Manufacturer.php @@ -31,40 +31,43 @@ use Symfony\Component\Validator\Constraints as Assert; /** * Class Manufacturer. - * - * @ORM\Entity(repositoryClass="App\Repository\Parts\ManufacturerRepository") - * @ORM\Table("`manufacturers`", indexes={ - * @ORM\Index(name="manufacturer_name", columns={"name"}), - * @ORM\Index(name="manufacturer_idx_parent_name", columns={"parent_id", "name"}), - * }) */ +#[ORM\Entity(repositoryClass: 'App\Repository\Parts\ManufacturerRepository')] +#[ORM\Table('`manufacturers`')] +#[ORM\Index(name: 'manufacturer_name', columns: ['name'])] +#[ORM\Index(name: 'manufacturer_idx_parent_name', columns: ['parent_id', 'name'])] class Manufacturer extends AbstractCompany { - /** - * @ORM\ManyToOne(targetEntity="Manufacturer", inversedBy="children") - * @ORM\JoinColumn(name="parent_id", referencedColumnName="id") - */ + #[ORM\ManyToOne(targetEntity: 'Manufacturer', inversedBy: 'children')] + #[ORM\JoinColumn(name: 'parent_id')] protected ?\App\Entity\Base\AbstractStructuralDBElement $parent; /** - * @ORM\OneToMany(targetEntity="Manufacturer", mappedBy="parent") - * @ORM\OrderBy({"name" = "ASC"}) * @var Collection */ + #[ORM\OneToMany(targetEntity: 'Manufacturer', mappedBy: 'parent')] + #[ORM\OrderBy(['name' => 'ASC'])] protected Collection $children; /** * @var Collection - * @ORM\OneToMany(targetEntity="App\Entity\Attachments\ManufacturerAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true) - * @ORM\OrderBy({"name" = "ASC"}) */ #[Assert\Valid] + #[ORM\OneToMany(targetEntity: 'App\Entity\Attachments\ManufacturerAttachment', mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)] + #[ORM\OrderBy(['name' => 'ASC'])] protected Collection $attachments; /** @var Collection - * @ORM\OneToMany(targetEntity="App\Entity\Parameters\ManufacturerParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true) - * @ORM\OrderBy({"group" = "ASC" ,"name" = "ASC"}) */ #[Assert\Valid] + #[ORM\OneToMany(targetEntity: 'App\Entity\Parameters\ManufacturerParameter', mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)] + #[ORM\OrderBy(['group' => 'ASC', 'name' => 'ASC'])] protected Collection $parameters; + public function __construct() + { + parent::__construct(); + $this->children = new \Doctrine\Common\Collections\ArrayCollection(); + $this->attachments = new \Doctrine\Common\Collections\ArrayCollection(); + $this->parameters = new \Doctrine\Common\Collections\ArrayCollection(); + } } diff --git a/src/Entity/Parts/MeasurementUnit.php b/src/Entity/Parts/MeasurementUnit.php index 10bfc90d..b36db648 100644 --- a/src/Entity/Parts/MeasurementUnit.php +++ b/src/Entity/Parts/MeasurementUnit.php @@ -34,68 +34,64 @@ use Symfony\Component\Validator\Constraints as Assert; /** * This unit represents the unit in which the amount of parts in stock are measured. * This could be something like N, grams, meters, etc... - * - * @ORM\Entity(repositoryClass="App\Repository\Parts\MeasurementUnitRepository") - * @ORM\Table(name="`measurement_units`", indexes={ - * @ORM\Index(name="unit_idx_name", columns={"name"}), - * @ORM\Index(name="unit_idx_parent_name", columns={"parent_id", "name"}), - * }) */ #[UniqueEntity('unit')] +#[ORM\Entity(repositoryClass: 'App\Repository\Parts\MeasurementUnitRepository')] +#[ORM\Table(name: '`measurement_units`')] +#[ORM\Index(name: 'unit_idx_name', columns: ['name'])] +#[ORM\Index(name: 'unit_idx_parent_name', columns: ['parent_id', 'name'])] class MeasurementUnit extends AbstractPartsContainingDBElement { /** * @var string The unit symbol that should be used for the Unit. This could be something like "", g (for grams) * or m (for meters). - * @ORM\Column(type="string", name="unit", nullable=true) */ #[Assert\Length(max: 10)] #[Groups(['extended', 'full', 'import'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, name: 'unit', nullable: true)] protected ?string $unit = null; /** * @var bool Determines if the amount value associated with this unit should be treated as integer. * Set to false, to measure continuous sizes likes masses or lengths. - * @ORM\Column(type="boolean", name="is_integer") */ #[Groups(['extended', 'full', 'import'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN, name: 'is_integer')] protected bool $is_integer = false; /** * @var bool Determines if the unit can be used with SI Prefixes (kilo, giga, milli, etc.). * Useful for sizes like meters. For this the unit must be set - * @ORM\Column(type="boolean", name="use_si_prefix") */ #[Assert\Expression('this.isUseSIPrefix() == false or this.getUnit() != null', message: 'validator.measurement_unit.use_si_prefix_needs_unit')] #[Groups(['full', 'import'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN, name: 'use_si_prefix')] protected bool $use_si_prefix = false; /** - * @ORM\OneToMany(targetEntity="MeasurementUnit", mappedBy="parent", cascade={"persist"}) - * @ORM\OrderBy({"name" = "ASC"}) * @var Collection */ + #[ORM\OneToMany(targetEntity: 'MeasurementUnit', mappedBy: 'parent', cascade: ['persist'])] + #[ORM\OrderBy(['name' => 'ASC'])] protected Collection $children; - /** - * @ORM\ManyToOne(targetEntity="MeasurementUnit", inversedBy="children") - * @ORM\JoinColumn(name="parent_id", referencedColumnName="id") - */ + #[ORM\ManyToOne(targetEntity: 'MeasurementUnit', inversedBy: 'children')] + #[ORM\JoinColumn(name: 'parent_id')] protected ?\App\Entity\Base\AbstractStructuralDBElement $parent; /** * @var Collection - * @ORM\OneToMany(targetEntity="App\Entity\Attachments\MeasurementUnitAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true) - * @ORM\OrderBy({"name" = "ASC"}) */ #[Assert\Valid] + #[ORM\OneToMany(targetEntity: 'App\Entity\Attachments\MeasurementUnitAttachment', mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)] + #[ORM\OrderBy(['name' => 'ASC'])] protected Collection $attachments; /** @var Collection - * @ORM\OneToMany(targetEntity="App\Entity\Parameters\MeasurementUnitParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true) - * @ORM\OrderBy({"group" = "ASC" ,"name" = "ASC"}) */ #[Assert\Valid] + #[ORM\OneToMany(targetEntity: 'App\Entity\Parameters\MeasurementUnitParameter', mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)] + #[ORM\OrderBy(['group' => 'ASC', 'name' => 'ASC'])] protected Collection $parameters; /** @@ -147,4 +143,11 @@ class MeasurementUnit extends AbstractPartsContainingDBElement return $this; } + public function __construct() + { + parent::__construct(); + $this->children = new \Doctrine\Common\Collections\ArrayCollection(); + $this->attachments = new \Doctrine\Common\Collections\ArrayCollection(); + $this->parameters = new \Doctrine\Common\Collections\ArrayCollection(); + } } diff --git a/src/Entity/Parts/PartTraits/AdvancedPropertyTrait.php b/src/Entity/Parts/PartTraits/AdvancedPropertyTrait.php index 43c0c57d..fe3db50b 100644 --- a/src/Entity/Parts/PartTraits/AdvancedPropertyTrait.php +++ b/src/Entity/Parts/PartTraits/AdvancedPropertyTrait.php @@ -34,32 +34,32 @@ trait AdvancedPropertyTrait { /** * @var bool Determines if this part entry needs review (for example, because it is work in progress) - * @ORM\Column(type="boolean") */ #[Groups(['extended', 'full', 'import'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN)] protected bool $needs_review = false; /** * @var string a comma separated list of tags, associated with the part - * @ORM\Column(type="text") */ #[Groups(['extended', 'full', 'import'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT)] protected string $tags = ''; /** * @var float|null how much a single part unit weighs in grams - * @ORM\Column(type="float", nullable=true) */ #[Assert\PositiveOrZero] #[Groups(['extended', 'full', 'import'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::FLOAT, nullable: true)] protected ?float $mass = null; /** * @var string|null The internal part number of the part - * @ORM\Column(type="string", length=100, nullable=true, unique=true) */ #[Assert\Length(max: 100)] #[Groups(['extended', 'full', 'import'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, length: 100, nullable: true, unique: true)] protected ?string $ipn = null; /** diff --git a/src/Entity/Parts/PartTraits/BasicPropertyTrait.php b/src/Entity/Parts/PartTraits/BasicPropertyTrait.php index 6dfc26ec..4d90a307 100644 --- a/src/Entity/Parts/PartTraits/BasicPropertyTrait.php +++ b/src/Entity/Parts/PartTraits/BasicPropertyTrait.php @@ -33,49 +33,49 @@ trait BasicPropertyTrait { /** * @var string A text describing what this part does - * @ORM\Column(type="text") */ #[Groups(['simple', 'extended', 'full', 'import'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT)] protected string $description = ''; /** * @var string A comment/note related to this part - * @ORM\Column(type="text") */ #[Groups(['extended', 'full', 'import'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT)] protected string $comment = ''; /** * @var bool Kept for compatibility (it is not used now, and I don't think it was used in old versions) - * @ORM\Column(type="boolean") */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN)] protected bool $visible = true; /** * @var bool true, if the part is marked as favorite - * @ORM\Column(type="boolean") */ #[Groups(['extended', 'full', 'import'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN)] protected bool $favorite = false; /** * @var Category|null The category this part belongs too (e.g. Resistors). Use tags, for more complex grouping. * Every part must have a category. - * @ORM\ManyToOne(targetEntity="Category") - * @ORM\JoinColumn(name="id_category", referencedColumnName="id", nullable=false) * @Selectable() */ #[Assert\NotNull(message: 'validator.select_valid_category')] #[Groups(['simple', 'extended', 'full', 'import'])] + #[ORM\ManyToOne(targetEntity: 'Category')] + #[ORM\JoinColumn(name: 'id_category', nullable: false)] protected ?Category $category = null; /** * @var Footprint|null The footprint of this part (e.g. DIP8) - * @ORM\ManyToOne(targetEntity="Footprint") - * @ORM\JoinColumn(name="id_footprint", referencedColumnName="id") * @Selectable() */ #[Groups(['simple', 'extended', 'full', 'import'])] + #[ORM\ManyToOne(targetEntity: 'Footprint')] + #[ORM\JoinColumn(name: 'id_footprint')] protected ?Footprint $footprint = null; /** diff --git a/src/Entity/Parts/PartTraits/InstockTrait.php b/src/Entity/Parts/PartTraits/InstockTrait.php index cf1da1e0..152ade10 100644 --- a/src/Entity/Parts/PartTraits/InstockTrait.php +++ b/src/Entity/Parts/PartTraits/InstockTrait.php @@ -36,28 +36,28 @@ trait InstockTrait { /** * @var Collection|PartLot[] A list of part lots where this part is stored - * @ORM\OneToMany(targetEntity="PartLot", mappedBy="part", cascade={"persist", "remove"}, orphanRemoval=true) - * @ORM\OrderBy({"amount" = "DESC"}) */ #[Assert\Valid] #[Groups(['extended', 'full', 'import'])] - protected $partLots; + #[ORM\OneToMany(targetEntity: 'PartLot', mappedBy: 'part', cascade: ['persist', 'remove'], orphanRemoval: true)] + #[ORM\OrderBy(['amount' => 'DESC'])] + protected \Doctrine\Common\Collections\Collection $partLots; /** * @var float The minimum amount of the part that has to be instock, otherwise more is ordered. * Given in the partUnit. - * @ORM\Column(type="float") */ #[Assert\PositiveOrZero] #[Groups(['extended', 'full', 'import'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::FLOAT)] protected float $minamount = 0; /** * @var ?MeasurementUnit the unit in which the part's amount is measured - * @ORM\ManyToOne(targetEntity="MeasurementUnit") - * @ORM\JoinColumn(name="id_part_unit", referencedColumnName="id", nullable=true) */ #[Groups(['extended', 'full', 'import'])] + #[ORM\ManyToOne(targetEntity: 'MeasurementUnit')] + #[ORM\JoinColumn(name: 'id_part_unit')] protected ?MeasurementUnit $partUnit = null; /** diff --git a/src/Entity/Parts/PartTraits/ManufacturerTrait.php b/src/Entity/Parts/PartTraits/ManufacturerTrait.php index fea580d0..d79a9128 100644 --- a/src/Entity/Parts/PartTraits/ManufacturerTrait.php +++ b/src/Entity/Parts/PartTraits/ManufacturerTrait.php @@ -36,34 +36,34 @@ trait ManufacturerTrait { /** * @var Manufacturer|null The manufacturer of this part - * @ORM\ManyToOne(targetEntity="Manufacturer") - * @ORM\JoinColumn(name="id_manufacturer", referencedColumnName="id") * @Selectable() */ #[Groups(['simple', 'extended', 'full', 'import'])] + #[ORM\ManyToOne(targetEntity: 'Manufacturer')] + #[ORM\JoinColumn(name: 'id_manufacturer')] protected ?Manufacturer $manufacturer = null; /** * @var string the url to the part on the manufacturer's homepage - * @ORM\Column(type="string") */ #[Assert\Url] #[Groups(['full', 'import'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING)] protected string $manufacturer_product_url = ''; /** * @var string The product number used by the manufacturer. If this is set to "", the name field is used. - * @ORM\Column(type="string") */ #[Groups(['extended', 'full', 'import'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING)] protected string $manufacturer_product_number = ''; /** * @var string|null The production status of this part. Can be one of the specified ones. - * @ORM\Column(type="string", length=255, nullable=true) */ #[Assert\Choice(['announced', 'active', 'nrfnd', 'eol', 'discontinued', ''])] #[Groups(['extended', 'full', 'import'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, length: 255, nullable: true)] protected ?string $manufacturing_status = ''; /** diff --git a/src/Entity/Parts/PartTraits/OrderTrait.php b/src/Entity/Parts/PartTraits/OrderTrait.php index b2feb024..b4e661a8 100644 --- a/src/Entity/Parts/PartTraits/OrderTrait.php +++ b/src/Entity/Parts/PartTraits/OrderTrait.php @@ -36,30 +36,30 @@ trait OrderTrait { /** * @var Orderdetail[]|Collection the details about how and where you can order this part - * @ORM\OneToMany(targetEntity="App\Entity\PriceInformations\Orderdetail", mappedBy="part", cascade={"persist", "remove"}, orphanRemoval=true) - * @ORM\OrderBy({"supplierpartnr" = "ASC"}) */ #[Assert\Valid] #[Groups(['extended', 'full', 'import'])] - protected $orderdetails; + #[ORM\OneToMany(targetEntity: 'App\Entity\PriceInformations\Orderdetail', mappedBy: 'part', cascade: ['persist', 'remove'], orphanRemoval: true)] + #[ORM\OrderBy(['supplierpartnr' => 'ASC'])] + protected \Doctrine\Common\Collections\Collection $orderdetails; /** * @var int - * @ORM\Column(type="integer") */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER)] protected int $order_quantity = 0; /** * @var bool - * @ORM\Column(type="boolean") */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN)] protected bool $manual_order = false; /** * @var Orderdetail|null - * @ORM\OneToOne(targetEntity="App\Entity\PriceInformations\Orderdetail") - * @ORM\JoinColumn(name="order_orderdetails_id", referencedColumnName="id") */ + #[ORM\OneToOne(targetEntity: 'App\Entity\PriceInformations\Orderdetail')] + #[ORM\JoinColumn(name: 'order_orderdetails_id')] protected ?Orderdetail $order_orderdetail = null; /** diff --git a/src/Entity/Parts/PartTraits/ProjectTrait.php b/src/Entity/Parts/PartTraits/ProjectTrait.php index e0d646d2..795b5393 100644 --- a/src/Entity/Parts/PartTraits/ProjectTrait.php +++ b/src/Entity/Parts/PartTraits/ProjectTrait.php @@ -10,16 +10,16 @@ use Doctrine\ORM\Mapping as ORM; trait ProjectTrait { /** - * @var Collection $project_bom_entries - * @ORM\OneToMany(targetEntity="App\Entity\ProjectSystem\ProjectBOMEntry", mappedBy="part", cascade={"remove"}, orphanRemoval=true) + * @var \Doctrine\Common\Collections\Collection<\App\Entity\ProjectSystem\ProjectBOMEntry> $project_bom_entries */ - protected $project_bom_entries = []; + #[ORM\OneToMany(targetEntity: 'App\Entity\ProjectSystem\ProjectBOMEntry', mappedBy: 'part', cascade: ['remove'], orphanRemoval: true)] + protected \Doctrine\Common\Collections\Collection $project_bom_entries = []; /** * @var Project|null If a project is set here, then this part is special and represents the builds of a project. - * @ORM\OneToOne(targetEntity="App\Entity\ProjectSystem\Project", inversedBy="build_part") - * @ORM\JoinColumn(nullable=true) */ + #[ORM\OneToOne(targetEntity: 'App\Entity\ProjectSystem\Project', inversedBy: 'build_part')] + #[ORM\JoinColumn] protected ?Project $built_project = null; /** diff --git a/src/Entity/Parts/Storelocation.php b/src/Entity/Parts/Storelocation.php index 3f18c79e..2249fb00 100644 --- a/src/Entity/Parts/Storelocation.php +++ b/src/Entity/Parts/Storelocation.php @@ -34,82 +34,78 @@ use Symfony\Component\Validator\Constraints as Assert; /** * Class Store location. - * - * @ORM\Entity(repositoryClass="App\Repository\Parts\StorelocationRepository") - * @ORM\Table("`storelocations`", indexes={ - * @ORM\Index(name="location_idx_name", columns={"name"}), - * @ORM\Index(name="location_idx_parent_name", columns={"parent_id", "name"}), - * }) */ +#[ORM\Entity(repositoryClass: 'App\Repository\Parts\StorelocationRepository')] +#[ORM\Table('`storelocations`')] +#[ORM\Index(name: 'location_idx_name', columns: ['name'])] +#[ORM\Index(name: 'location_idx_parent_name', columns: ['parent_id', 'name'])] class Storelocation extends AbstractPartsContainingDBElement { /** - * @ORM\OneToMany(targetEntity="Storelocation", mappedBy="parent") - * @ORM\OrderBy({"name" = "ASC"}) * @var Collection */ + #[ORM\OneToMany(targetEntity: 'Storelocation', mappedBy: 'parent')] + #[ORM\OrderBy(['name' => 'ASC'])] protected Collection $children; - /** - * @ORM\ManyToOne(targetEntity="Storelocation", inversedBy="children") - * @ORM\JoinColumn(name="parent_id", referencedColumnName="id") - */ + #[ORM\ManyToOne(targetEntity: 'Storelocation', inversedBy: 'children')] + #[ORM\JoinColumn(name: 'parent_id')] protected ?AbstractStructuralDBElement $parent; /** * @var MeasurementUnit|null The measurement unit, which parts can be stored in here - * @ORM\ManyToOne(targetEntity="MeasurementUnit") - * @ORM\JoinColumn(name="storage_type_id", referencedColumnName="id") */ + #[ORM\ManyToOne(targetEntity: 'MeasurementUnit')] + #[ORM\JoinColumn(name: 'storage_type_id')] protected ?MeasurementUnit $storage_type = null; /** @var Collection - * @ORM\OneToMany(targetEntity="App\Entity\Parameters\StorelocationParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true) - * @ORM\OrderBy({"group" = "ASC" ,"name" = "ASC"}) */ #[Assert\Valid] + #[ORM\OneToMany(targetEntity: 'App\Entity\Parameters\StorelocationParameter', mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)] + #[ORM\OrderBy(['group' => 'ASC', 'name' => 'ASC'])] protected Collection $parameters; /** * @var bool - * @ORM\Column(type="boolean") */ #[Groups(['full', 'import'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN)] protected bool $is_full = false; /** * @var bool - * @ORM\Column(type="boolean") */ #[Groups(['full', 'import'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN)] protected bool $only_single_part = false; /** * @var bool - * @ORM\Column(type="boolean") */ #[Groups(['full', 'import'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN)] protected bool $limit_to_existing_parts = false; /** * @var User|null The owner of this storage location - * @ORM\ManyToOne(targetEntity="App\Entity\UserSystem\User") - * @ORM\JoinColumn(name="id_owner", referencedColumnName="id", nullable=true, onDelete="SET NULL") */ #[Assert\Expression('this.getOwner() == null or this.getOwner().isAnonymousUser() === false', message: 'validator.part_lot.owner_must_not_be_anonymous')] + #[ORM\ManyToOne(targetEntity: 'App\Entity\UserSystem\User')] + #[ORM\JoinColumn(name: 'id_owner', onDelete: 'SET NULL')] protected ?User $owner = null; /** * @var bool If this is set to true, only parts lots, which are owned by the same user as the store location are allowed to be stored here. - * @ORM\Column(type="boolean", options={"default":false}) */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN, options: ['default' => false])] protected bool $part_owner_must_match = false; /** * @var Collection - * @ORM\OneToMany(targetEntity="App\Entity\Attachments\StorelocationAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true) */ #[Assert\Valid] + #[ORM\OneToMany(targetEntity: 'App\Entity\Attachments\StorelocationAttachment', mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)] protected Collection $attachments; /******************************************************************************** @@ -248,4 +244,11 @@ class Storelocation extends AbstractPartsContainingDBElement return $this; } + public function __construct() + { + parent::__construct(); + $this->children = new \Doctrine\Common\Collections\ArrayCollection(); + $this->parameters = new \Doctrine\Common\Collections\ArrayCollection(); + $this->attachments = new \Doctrine\Common\Collections\ArrayCollection(); + } } diff --git a/src/Entity/Parts/Supplier.php b/src/Entity/Parts/Supplier.php index 95fd25fe..65b82fec 100644 --- a/src/Entity/Parts/Supplier.php +++ b/src/Entity/Parts/Supplier.php @@ -37,63 +37,60 @@ use Symfony\Component\Validator\Constraints as Assert; /** * Class Supplier. - * - * @ORM\Entity(repositoryClass="App\Repository\Parts\SupplierRepository") - * @ORM\Table("`suppliers`", indexes={ - * @ORM\Index(name="supplier_idx_name", columns={"name"}), - * @ORM\Index(name="supplier_idx_parent_name", columns={"parent_id", "name"}), - * }) */ +#[ORM\Entity(repositoryClass: 'App\Repository\Parts\SupplierRepository')] +#[ORM\Table('`suppliers`')] +#[ORM\Index(name: 'supplier_idx_name', columns: ['name'])] +#[ORM\Index(name: 'supplier_idx_parent_name', columns: ['parent_id', 'name'])] class Supplier extends AbstractCompany { /** - * @ORM\OneToMany(targetEntity="Supplier", mappedBy="parent") - * @ORM\OrderBy({"name" = "ASC"}) * @var Collection */ + #[ORM\OneToMany(targetEntity: 'Supplier', mappedBy: 'parent')] + #[ORM\OrderBy(['name' => 'ASC'])] protected Collection $children; - /** - * @ORM\ManyToOne(targetEntity="Supplier", inversedBy="children") - * @ORM\JoinColumn(name="parent_id", referencedColumnName="id") - */ + #[ORM\ManyToOne(targetEntity: 'Supplier', inversedBy: 'children')] + #[ORM\JoinColumn(name: 'parent_id')] protected ?AbstractStructuralDBElement $parent; /** - * @ORM\OneToMany(targetEntity="App\Entity\PriceInformations\Orderdetail", mappedBy="supplier") + * @var \Doctrine\Common\Collections\Collection|\App\Entity\PriceInformations\Orderdetail[] */ + #[ORM\OneToMany(targetEntity: 'App\Entity\PriceInformations\Orderdetail', mappedBy: 'supplier')] protected Collection $orderdetails; /** * @var Currency|null The currency that should be used by default for order informations with this supplier. * Set to null, to use global base currency. - * @ORM\ManyToOne(targetEntity="App\Entity\PriceInformations\Currency") - * @ORM\JoinColumn(name="default_currency_id", referencedColumnName="id", nullable=true) * @Selectable() */ + #[ORM\ManyToOne(targetEntity: 'App\Entity\PriceInformations\Currency')] + #[ORM\JoinColumn(name: 'default_currency_id')] protected ?Currency $default_currency = null; /** * @var BigDecimal|null the shipping costs that have to be paid, when ordering via this supplier - * @ORM\Column(name="shipping_costs", nullable=true, type="big_decimal", precision=11, scale=5) * @BigDecimalPositiveOrZero() */ #[Groups(['extended', 'full', 'import'])] + #[ORM\Column(name: 'shipping_costs', nullable: true, type: 'big_decimal', precision: 11, scale: 5)] protected ?BigDecimal $shipping_costs = null; /** * @var Collection - * @ORM\OneToMany(targetEntity="App\Entity\Attachments\SupplierAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true) - * @ORM\OrderBy({"name" = "ASC"}) */ #[Assert\Valid] + #[ORM\OneToMany(targetEntity: 'App\Entity\Attachments\SupplierAttachment', mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)] + #[ORM\OrderBy(['name' => 'ASC'])] protected Collection $attachments; /** @var Collection - * @ORM\OneToMany(targetEntity="App\Entity\Parameters\SupplierParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true) - * @ORM\OrderBy({"group" = "ASC" ,"name" = "ASC"}) */ #[Assert\Valid] + #[ORM\OneToMany(targetEntity: 'App\Entity\Parameters\SupplierParameter', mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)] + #[ORM\OrderBy(['group' => 'ASC', 'name' => 'ASC'])] protected Collection $parameters; /** @@ -146,4 +143,12 @@ class Supplier extends AbstractCompany return $this; } + public function __construct() + { + parent::__construct(); + $this->children = new \Doctrine\Common\Collections\ArrayCollection(); + $this->orderdetails = new \Doctrine\Common\Collections\ArrayCollection(); + $this->attachments = new \Doctrine\Common\Collections\ArrayCollection(); + $this->parameters = new \Doctrine\Common\Collections\ArrayCollection(); + } } diff --git a/src/Entity/PriceInformations/Currency.php b/src/Entity/PriceInformations/Currency.php index ee90cdd3..f434c1ff 100644 --- a/src/Entity/PriceInformations/Currency.php +++ b/src/Entity/PriceInformations/Currency.php @@ -37,14 +37,12 @@ use Symfony\Component\Validator\Constraints as Assert; /** * This entity describes a currency that can be used for price information. - * - * @ORM\Entity() - * @ORM\Table(name="currencies", indexes={ - * @ORM\Index(name="currency_idx_name", columns={"name"}), - * @ORM\Index(name="currency_idx_parent_name", columns={"parent_id", "name"}), - * }) */ #[UniqueEntity('iso_code')] +#[ORM\Entity] +#[ORM\Table(name: 'currencies')] +#[ORM\Index(name: 'currency_idx_name', columns: ['name'])] +#[ORM\Index(name: 'currency_idx_parent_name', columns: ['parent_id', 'name'])] class Currency extends AbstractStructuralDBElement { public const PRICE_SCALE = 5; @@ -52,53 +50,52 @@ class Currency extends AbstractStructuralDBElement /** * @var BigDecimal|null The exchange rate between this currency and the base currency * (how many base units the current currency is worth) - * @ORM\Column(type="big_decimal", precision=11, scale=5, nullable=true) * @BigDecimalPositive() */ + #[ORM\Column(type: 'big_decimal', precision: 11, scale: 5, nullable: true)] protected ?BigDecimal $exchange_rate = null; /** * @var string the 3-letter ISO code of the currency - * @ORM\Column(type="string") */ #[Assert\Currency] #[Groups(['extended', 'full', 'import'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING)] protected string $iso_code = ""; - /** - * @ORM\OneToMany(targetEntity="Currency", mappedBy="parent", cascade={"persist"}) - * @ORM\OrderBy({"name" = "ASC"}) - */ + #[ORM\OneToMany(targetEntity: 'Currency', mappedBy: 'parent', cascade: ['persist'])] + #[ORM\OrderBy(['name' => 'ASC'])] protected Collection $children; - /** - * @ORM\ManyToOne(targetEntity="Currency", inversedBy="children") - * @ORM\JoinColumn(name="parent_id", referencedColumnName="id") - */ + #[ORM\ManyToOne(targetEntity: 'Currency', inversedBy: 'children')] + #[ORM\JoinColumn(name: 'parent_id')] protected ?AbstractStructuralDBElement $parent; /** * @var Collection - * @ORM\OneToMany(targetEntity="App\Entity\Attachments\CurrencyAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true) - * @ORM\OrderBy({"name" = "ASC"}) */ #[Assert\Valid] + #[ORM\OneToMany(targetEntity: 'App\Entity\Attachments\CurrencyAttachment', mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)] + #[ORM\OrderBy(['name' => 'ASC'])] protected Collection $attachments; /** @var Collection - * @ORM\OneToMany(targetEntity="App\Entity\Parameters\CurrencyParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true) - * @ORM\OrderBy({"group" = "ASC" ,"name" = "ASC"}) */ #[Assert\Valid] + #[ORM\OneToMany(targetEntity: 'App\Entity\Parameters\CurrencyParameter', mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)] + #[ORM\OrderBy(['group' => 'ASC', 'name' => 'ASC'])] protected Collection $parameters; /** @var Collection - * @ORM\OneToMany(targetEntity="App\Entity\PriceInformations\Pricedetail", mappedBy="currency") */ + #[ORM\OneToMany(targetEntity: 'App\Entity\PriceInformations\Pricedetail', mappedBy: 'currency')] protected Collection $pricedetails; public function __construct() { + $this->children = new \Doctrine\Common\Collections\ArrayCollection(); + $this->attachments = new \Doctrine\Common\Collections\ArrayCollection(); + $this->parameters = new \Doctrine\Common\Collections\ArrayCollection(); $this->pricedetails = new ArrayCollection(); parent::__construct(); } diff --git a/src/Entity/PriceInformations/Orderdetail.php b/src/Entity/PriceInformations/Orderdetail.php index 366f9b81..9fce1a5f 100644 --- a/src/Entity/PriceInformations/Orderdetail.php +++ b/src/Entity/PriceInformations/Orderdetail.php @@ -39,63 +39,59 @@ use Symfony\Component\Validator\Constraints as Assert; /** * Class Orderdetail. - * - * @ORM\Table("`orderdetails`", indexes={ - * @ORM\Index(name="orderdetails_supplier_part_nr", columns={"supplierpartnr"}), - * }) - * @ORM\Entity() - * @ORM\HasLifecycleCallbacks() */ #[UniqueEntity(['supplierpartnr', 'supplier', 'part'])] +#[ORM\Entity] +#[ORM\HasLifecycleCallbacks] +#[ORM\Table('`orderdetails`')] +#[ORM\Index(name: 'orderdetails_supplier_part_nr', columns: ['supplierpartnr'])] class Orderdetail extends AbstractDBElement implements TimeStampableInterface, NamedElementInterface { use TimestampTrait; - /** - * @ORM\OneToMany(targetEntity="Pricedetail", mappedBy="orderdetail", cascade={"persist", "remove"}, orphanRemoval=true) - * @ORM\OrderBy({"min_discount_quantity" = "ASC"}) - */ #[Assert\Valid] #[Groups(['extended', 'full', 'import'])] + #[ORM\OneToMany(targetEntity: 'Pricedetail', mappedBy: 'orderdetail', cascade: ['persist', 'remove'], orphanRemoval: true)] + #[ORM\OrderBy(['min_discount_quantity' => 'ASC'])] protected Collection $pricedetails; /** * @var string - * @ORM\Column(type="string") */ #[Groups(['extended', 'full', 'import'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING)] protected string $supplierpartnr = ''; /** * @var bool - * @ORM\Column(type="boolean") */ #[Groups(['extended', 'full', 'import'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN)] protected bool $obsolete = false; /** * @var string - * @ORM\Column(type="string") */ #[Assert\Url] #[Groups(['full', 'import'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING)] protected string $supplier_product_url = ''; /** * @var Part|null - * @ORM\ManyToOne(targetEntity="App\Entity\Parts\Part", inversedBy="orderdetails") - * @ORM\JoinColumn(name="part_id", referencedColumnName="id", nullable=false, onDelete="CASCADE") */ #[Assert\NotNull] + #[ORM\ManyToOne(targetEntity: 'App\Entity\Parts\Part', inversedBy: 'orderdetails')] + #[ORM\JoinColumn(name: 'part_id', nullable: false, onDelete: 'CASCADE')] protected ?Part $part = null; /** * @var Supplier|null - * @ORM\ManyToOne(targetEntity="App\Entity\Parts\Supplier", inversedBy="orderdetails") - * @ORM\JoinColumn(name="id_supplier", referencedColumnName="id") */ #[Assert\NotNull(message: 'validator.orderdetail.supplier_must_not_be_null')] #[Groups(['extended', 'full', 'import'])] + #[ORM\ManyToOne(targetEntity: 'App\Entity\Parts\Supplier', inversedBy: 'orderdetails')] + #[ORM\JoinColumn(name: 'id_supplier')] protected ?Supplier $supplier = null; public function __construct() @@ -119,10 +115,9 @@ class Orderdetail extends AbstractDBElement implements TimeStampableInterface, N /** * Helper for updating the timestamp. It is automatically called by doctrine before persisting. - * - * @ORM\PrePersist - * @ORM\PreUpdate */ + #[ORM\PrePersist] + #[ORM\PreUpdate] public function updateTimestamps(): void { $this->lastModified = new DateTime('now'); diff --git a/src/Entity/PriceInformations/Pricedetail.php b/src/Entity/PriceInformations/Pricedetail.php index b4a0cbc6..b9af1e5b 100644 --- a/src/Entity/PriceInformations/Pricedetail.php +++ b/src/Entity/PriceInformations/Pricedetail.php @@ -37,15 +37,13 @@ use Symfony\Component\Validator\Constraints as Assert; /** * Class Pricedetail. - * - * @ORM\Entity() - * @ORM\Table("`pricedetails`", indexes={ - * @ORM\Index(name="pricedetails_idx_min_discount", columns={"min_discount_quantity"}), - * @ORM\Index(name="pricedetails_idx_min_discount_price_qty", columns={"min_discount_quantity", "price_related_quantity"}), - * }) - * @ORM\HasLifecycleCallbacks() */ #[UniqueEntity(fields: ['min_discount_quantity', 'orderdetail'])] +#[ORM\Entity] +#[ORM\HasLifecycleCallbacks] +#[ORM\Table('`pricedetails`')] +#[ORM\Index(name: 'pricedetails_idx_min_discount', columns: ['min_discount_quantity'])] +#[ORM\Index(name: 'pricedetails_idx_min_discount_price_qty', columns: ['min_discount_quantity', 'price_related_quantity'])] class Pricedetail extends AbstractDBElement implements TimeStampableInterface { use TimestampTrait; @@ -54,50 +52,50 @@ class Pricedetail extends AbstractDBElement implements TimeStampableInterface /** * @var BigDecimal The price related to the detail. (Given in the selected currency) - * @ORM\Column(type="big_decimal", precision=11, scale=5) * @BigDecimalPositive() */ #[Groups(['extended', 'full'])] + #[ORM\Column(type: 'big_decimal', precision: 11, scale: 5)] protected BigDecimal $price; /** * @var ?Currency The currency used for the current price information. * If this is null, the global base unit is assumed. - * @ORM\ManyToOne(targetEntity="Currency", inversedBy="pricedetails") - * @ORM\JoinColumn(name="id_currency", referencedColumnName="id", nullable=true) * @Selectable() */ #[Groups(['extended', 'full', 'import'])] + #[ORM\ManyToOne(targetEntity: 'Currency', inversedBy: 'pricedetails')] + #[ORM\JoinColumn(name: 'id_currency')] protected ?Currency $currency = null; /** * @var float - * @ORM\Column(type="float") */ #[Assert\Positive] #[Groups(['extended', 'full', 'import'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::FLOAT)] protected float $price_related_quantity = 1.0; /** * @var float - * @ORM\Column(type="float") */ #[Assert\Positive] #[Groups(['extended', 'full', 'import'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::FLOAT)] protected float $min_discount_quantity = 1.0; /** * @var bool - * @ORM\Column(type="boolean") */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN)] protected bool $manual_input = true; /** * @var Orderdetail|null - * @ORM\ManyToOne(targetEntity="Orderdetail", inversedBy="pricedetails") - * @ORM\JoinColumn(name="orderdetails_id", referencedColumnName="id", nullable=false, onDelete="CASCADE") */ #[Assert\NotNull] + #[ORM\ManyToOne(targetEntity: 'Orderdetail', inversedBy: 'pricedetails')] + #[ORM\JoinColumn(name: 'orderdetails_id', nullable: false, onDelete: 'CASCADE')] protected ?Orderdetail $orderdetail = null; public function __construct() @@ -115,10 +113,9 @@ class Pricedetail extends AbstractDBElement implements TimeStampableInterface /** * Helper for updating the timestamp. It is automatically called by doctrine before persisting. - * - * @ORM\PrePersist - * @ORM\PreUpdate */ + #[ORM\PrePersist] + #[ORM\PreUpdate] public function updateTimestamps(): void { $this->lastModified = new DateTime('now'); diff --git a/src/Entity/ProjectSystem/Project.php b/src/Entity/ProjectSystem/Project.php index 13bc4832..a539e6cf 100644 --- a/src/Entity/ProjectSystem/Project.php +++ b/src/Entity/ProjectSystem/Project.php @@ -36,74 +36,63 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface; /** * Class AttachmentType. - * - * @ORM\Entity(repositoryClass="App\Repository\Parts\DeviceRepository") - * @ORM\Table(name="projects") */ +#[ORM\Entity(repositoryClass: 'App\Repository\Parts\DeviceRepository')] +#[ORM\Table(name: 'projects')] class Project extends AbstractStructuralDBElement { /** - * @ORM\OneToMany(targetEntity="Project", mappedBy="parent") - * @ORM\OrderBy({"name" = "ASC"}) * @var Collection */ + #[ORM\OneToMany(targetEntity: 'Project', mappedBy: 'parent')] + #[ORM\OrderBy(['name' => 'ASC'])] protected Collection $children; - /** - * @ORM\ManyToOne(targetEntity="Project", inversedBy="children") - * @ORM\JoinColumn(name="parent_id", referencedColumnName="id") - */ + #[ORM\ManyToOne(targetEntity: 'Project', inversedBy: 'children')] + #[ORM\JoinColumn(name: 'parent_id')] protected ?AbstractStructuralDBElement $parent; - /** - * @ORM\OneToMany(targetEntity="ProjectBOMEntry", mappedBy="project", cascade={"persist", "remove"}, orphanRemoval=true) - */ #[Assert\Valid] #[Groups(['extended', 'full'])] + #[ORM\OneToMany(targetEntity: 'ProjectBOMEntry', mappedBy: 'project', cascade: ['persist', 'remove'], orphanRemoval: true)] protected Collection $bom_entries; - /** - * @ORM\Column(type="integer") - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER)] protected int $order_quantity = 0; /** * @var string|null The current status of the project - * @ORM\Column(type="string", length=64, nullable=true) */ #[Assert\Choice(['draft', 'planning', 'in_production', 'finished', 'archived'])] #[Groups(['extended', 'full'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, length: 64, nullable: true)] protected ?string $status = null; /** * @var Part|null The (optional) part that represents the builds of this project in the stock - * @ORM\OneToOne(targetEntity="App\Entity\Parts\Part", mappedBy="built_project", cascade={"persist"}, orphanRemoval=true) */ + #[ORM\OneToOne(targetEntity: 'App\Entity\Parts\Part', mappedBy: 'built_project', cascade: ['persist'], orphanRemoval: true)] protected ?Part $build_part = null; - /** - * @ORM\Column(type="boolean") - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN)] protected bool $order_only_missing_parts = false; - /** - * @ORM\Column(type="text", nullable=false) - */ #[Groups(['simple', 'extended', 'full'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT)] protected string $description = ''; /** * @var Collection - * @ORM\OneToMany(targetEntity="App\Entity\Attachments\ProjectAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true) - * @ORM\OrderBy({"name" = "ASC"}) */ + #[ORM\OneToMany(targetEntity: 'App\Entity\Attachments\ProjectAttachment', mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)] + #[ORM\OrderBy(['name' => 'ASC'])] protected Collection $attachments; /** @var Collection - * @ORM\OneToMany(targetEntity="App\Entity\Parameters\ProjectParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true) - * @ORM\OrderBy({"group" = "ASC" ,"name" = "ASC"}) */ + #[ORM\OneToMany(targetEntity: 'App\Entity\Parameters\ProjectParameter', mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)] + #[ORM\OrderBy(['group' => 'ASC', 'name' => 'ASC'])] protected Collection $parameters; /******************************************************************************** @@ -114,6 +103,8 @@ class Project extends AbstractStructuralDBElement public function __construct() { + $this->attachments = new \Doctrine\Common\Collections\ArrayCollection(); + $this->parameters = new \Doctrine\Common\Collections\ArrayCollection(); parent::__construct(); $this->bom_entries = new ArrayCollection(); $this->children = new ArrayCollection(); diff --git a/src/Entity/ProjectSystem/ProjectBOMEntry.php b/src/Entity/ProjectSystem/ProjectBOMEntry.php index cc8f5fde..04be2862 100644 --- a/src/Entity/ProjectSystem/ProjectBOMEntry.php +++ b/src/Entity/ProjectSystem/ProjectBOMEntry.php @@ -36,70 +36,69 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface; /** * The ProjectBOMEntry class represents an entry in a project's BOM. - * - * @ORM\Table("project_bom_entries") - * @ORM\HasLifecycleCallbacks() - * @ORM\Entity() */ #[UniqueEntity(fields: ['part', 'project'], message: 'project.bom_entry.part_already_in_bom')] #[UniqueEntity(fields: ['name', 'project'], message: 'project.bom_entry.name_already_in_bom', ignoreNull: true)] +#[ORM\HasLifecycleCallbacks] +#[ORM\Entity] +#[ORM\Table('project_bom_entries')] class ProjectBOMEntry extends AbstractDBElement { use TimestampTrait; /** * @var float - * @ORM\Column(type="float", name="quantity") */ #[Assert\Positive] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::FLOAT, name: 'quantity')] protected float $quantity; /** * @var string A comma separated list of the names, where this parts should be placed - * @ORM\Column(type="text", name="mountnames") */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT, name: 'mountnames')] protected string $mountnames = ''; /** * @var string|null An optional name describing this BOM entry (useful for non-part entries) - * @ORM\Column(type="string", nullable=true) */ #[Assert\Expression('this.getPart() !== null or this.getName() !== null', message: 'validator.project.bom_entry.name_or_part_needed')] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, nullable: true)] protected ?string $name = null; /** * @var string An optional comment for this BOM entry - * @ORM\Column(type="text") */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT)] protected string $comment; /** * @var Project|null - * @ORM\ManyToOne(targetEntity="Project", inversedBy="bom_entries") - * @ORM\JoinColumn(name="id_device", referencedColumnName="id") */ + #[ORM\ManyToOne(targetEntity: 'Project', inversedBy: 'bom_entries')] + #[ORM\JoinColumn(name: 'id_device')] protected ?Project $project = null; /** * @var Part|null The part associated with this - * @ORM\ManyToOne(targetEntity="App\Entity\Parts\Part", inversedBy="project_bom_entries") - * @ORM\JoinColumn(name="id_part", referencedColumnName="id", nullable=true) */ + #[ORM\ManyToOne(targetEntity: 'App\Entity\Parts\Part', inversedBy: 'project_bom_entries')] + #[ORM\JoinColumn(name: 'id_part')] protected ?Part $part = null; /** * @var BigDecimal|null The price of this non-part BOM entry - * @ORM\Column(type="big_decimal", precision=11, scale=5, nullable=true) */ #[Assert\AtLeastOneOf([new BigDecimalPositive(), new Assert\IsNull()])] + #[ORM\Column(type: 'big_decimal', precision: 11, scale: 5, nullable: true)] protected ?BigDecimal $price; /** * @var ?Currency The currency for the price of this non-part BOM entry - * @ORM\ManyToOne(targetEntity="App\Entity\PriceInformations\Currency") - * @ORM\JoinColumn(nullable=true) * @Selectable() */ + #[ORM\ManyToOne(targetEntity: 'App\Entity\PriceInformations\Currency')] + #[ORM\JoinColumn] protected ?Currency $price_currency = null; public function __construct() diff --git a/src/Entity/UserSystem/Group.php b/src/Entity/UserSystem/Group.php index 05c2b205..663e9fed 100644 --- a/src/Entity/UserSystem/Group.php +++ b/src/Entity/UserSystem/Group.php @@ -35,65 +35,63 @@ use Symfony\Component\Validator\Constraints as Assert; /** * This entity represents a user group. - * - * @ORM\Entity() - * @ORM\Table("`groups`", indexes={ - * @ORM\Index(name="group_idx_name", columns={"name"}), - * @ORM\Index(name="group_idx_parent_name", columns={"parent_id", "name"}), - * }) */ +#[ORM\Entity] +#[ORM\Table('`groups`')] +#[ORM\Index(name: 'group_idx_name', columns: ['name'])] +#[ORM\Index(name: 'group_idx_parent_name', columns: ['parent_id', 'name'])] class Group extends AbstractStructuralDBElement implements HasPermissionsInterface { /** - * @ORM\OneToMany(targetEntity="Group", mappedBy="parent") - * @ORM\OrderBy({"name" = "ASC"}) * @var Collection */ + #[ORM\OneToMany(targetEntity: 'Group', mappedBy: 'parent')] + #[ORM\OrderBy(['name' => 'ASC'])] protected Collection $children; - /** - * @ORM\ManyToOne(targetEntity="Group", inversedBy="children") - * @ORM\JoinColumn(name="parent_id", referencedColumnName="id") - */ + #[ORM\ManyToOne(targetEntity: 'Group', inversedBy: 'children')] + #[ORM\JoinColumn(name: 'parent_id')] protected ?AbstractStructuralDBElement $parent; /** - * @ORM\OneToMany(targetEntity="User", mappedBy="group") * @var Collection */ + #[ORM\OneToMany(targetEntity: 'User', mappedBy: 'group')] protected Collection $users; /** * @var bool If true all users associated with this group must have enabled some kind of two-factor authentication - * @ORM\Column(type="boolean", name="enforce_2fa") */ #[Groups(['extended', 'full', 'import'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN, name: 'enforce_2fa')] protected bool $enforce2FA = false; /** * @var Collection - * @ORM\OneToMany(targetEntity="App\Entity\Attachments\GroupAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true) - * @ORM\OrderBy({"name" = "ASC"}) */ #[Assert\Valid] + #[ORM\OneToMany(targetEntity: 'App\Entity\Attachments\GroupAttachment', mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)] + #[ORM\OrderBy(['name' => 'ASC'])] protected Collection $attachments; /** * @var PermissionData|null * @ValidPermission() - * @ORM\Embedded(class="PermissionData", columnPrefix="permissions_") */ #[Groups(['full'])] + #[ORM\Embedded(class: 'PermissionData', columnPrefix: 'permissions_')] protected ?PermissionData $permissions = null; /** @var Collection - * @ORM\OneToMany(targetEntity="App\Entity\Parameters\GroupParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true) - * @ORM\OrderBy({"group" = "ASC" ,"name" = "ASC"}) */ #[Assert\Valid] + #[ORM\OneToMany(targetEntity: 'App\Entity\Parameters\GroupParameter', mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)] + #[ORM\OrderBy(['group' => 'ASC', 'name' => 'ASC'])] protected Collection $parameters; public function __construct() { + $this->attachments = new \Doctrine\Common\Collections\ArrayCollection(); + $this->parameters = new \Doctrine\Common\Collections\ArrayCollection(); parent::__construct(); $this->permissions = new PermissionData(); $this->users = new ArrayCollection(); diff --git a/src/Entity/UserSystem/PermissionData.php b/src/Entity/UserSystem/PermissionData.php index d67ee866..9d6c4cf2 100644 --- a/src/Entity/UserSystem/PermissionData.php +++ b/src/Entity/UserSystem/PermissionData.php @@ -25,9 +25,8 @@ use Doctrine\ORM\Mapping as ORM; /** * This class is used to store the permissions of a user. * This has to be an embeddable or otherwise doctrine could not track the changes of the underlying data array (which is serialized to JSON in the database) - * - * @ORM\Embeddable() */ +#[ORM\Embeddable] final class PermissionData implements \JsonSerializable { /** @@ -48,8 +47,8 @@ final class PermissionData implements \JsonSerializable * permission => [ * operation => value, * ] - * @ORM\Column(type="json", name="data") */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON, name: 'data')] protected ?array $data = [ //$ prefixed entries are used for metadata '$ver' => self::CURRENT_SCHEMA_VERSION, //The schema version of the permission data diff --git a/src/Entity/UserSystem/U2FKey.php b/src/Entity/UserSystem/U2FKey.php index 9c1c68a3..8bc86705 100644 --- a/src/Entity/UserSystem/U2FKey.php +++ b/src/Entity/UserSystem/U2FKey.php @@ -26,15 +26,10 @@ use App\Entity\Base\TimestampTrait; use Doctrine\ORM\Mapping as ORM; use Jbtronics\TFAWebauthn\Model\LegacyU2FKeyInterface; -/** - * @ORM\Entity - * @ORM\Table(name="u2f_keys", - * uniqueConstraints={ - * @ORM\UniqueConstraint(name="user_unique",columns={"user_id", - * "key_handle"}) - * }) - * @ORM\HasLifecycleCallbacks() - */ +#[ORM\Entity] +#[ORM\HasLifecycleCallbacks] +#[ORM\Table(name: 'u2f_keys')] +#[ORM\UniqueConstraint(name: 'user_unique', columns: ['user_id', 'key_handle'])] class U2FKey implements LegacyU2FKeyInterface { use TimestampTrait; @@ -43,50 +38,42 @@ class U2FKey implements LegacyU2FKeyInterface * We have to restrict the length here, as InnoDB only supports key index with max. 767 Bytes. * Max length of keyhandles should be 128. (According to U2F_MAX_KH_SIZE in FIDO example C code). * - * @ORM\Column(type="string", length=128) * * @var string **/ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, length: 128)] public string $keyHandle; /** - * @ORM\Column(type="string") - * * @var string **/ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING)] public string $publicKey; /** - * @ORM\Column(type="text") - * * @var string **/ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT)] public string $certificate; /** - * @ORM\Column(type="string") - * * @var int **/ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING)] public int $counter; - /** - * @ORM\Id - * @ORM\Column(type="integer") - * @ORM\GeneratedValue(strategy="AUTO") - */ + #[ORM\Id] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER)] + #[ORM\GeneratedValue] protected int $id; /** - * @ORM\Column(type="string") - * * @var string **/ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING)] protected string $name; - /** - * @ORM\ManyToOne(targetEntity="App\Entity\UserSystem\User", inversedBy="u2fKeys") - **/ + #[ORM\ManyToOne(targetEntity: 'App\Entity\UserSystem\User', inversedBy: 'u2fKeys')] protected ?User $user = null; public function getKeyHandle(): string diff --git a/src/Entity/UserSystem/WebauthnKey.php b/src/Entity/UserSystem/WebauthnKey.php index 5d5c654d..fd43ad33 100644 --- a/src/Entity/UserSystem/WebauthnKey.php +++ b/src/Entity/UserSystem/WebauthnKey.php @@ -24,30 +24,22 @@ use App\Entity\Base\TimestampTrait; use Doctrine\ORM\Mapping as ORM; use Webauthn\PublicKeyCredentialSource as BasePublicKeyCredentialSource; -/** - * @ORM\Table(name="webauthn_keys") - * @ORM\Entity() - * @ORM\HasLifecycleCallbacks() - */ +#[ORM\Entity] +#[ORM\HasLifecycleCallbacks] +#[ORM\Table(name: 'webauthn_keys')] class WebauthnKey extends BasePublicKeyCredentialSource { use TimestampTrait; - /** - * @ORM\Id - * @ORM\Column(type="integer") - * @ORM\GeneratedValue(strategy="AUTO") - */ + #[ORM\Id] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER)] + #[ORM\GeneratedValue] protected int $id; - /** - * @ORM\Column(type="string") - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING)] protected string $name; - /** - * @ORM\ManyToOne(targetEntity="App\Entity\UserSystem\User", inversedBy="webauthn_keys") - **/ + #[ORM\ManyToOne(targetEntity: 'App\Entity\UserSystem\User', inversedBy: 'webauthn_keys')] protected ?User $user = null; /** diff --git a/src/EntityListeners/AttachmentDeleteListener.php b/src/EntityListeners/AttachmentDeleteListener.php index 84d588c7..430740cb 100644 --- a/src/EntityListeners/AttachmentDeleteListener.php +++ b/src/EntityListeners/AttachmentDeleteListener.php @@ -54,9 +54,8 @@ class AttachmentDeleteListener /** * Removes the file associated with the attachment, if the file associated with the attachment changes. - * - * @PreUpdate */ + #[PreUpdate] public function preUpdateHandler(Attachment $attachment, PreUpdateEventArgs $event): void { if ($event->hasChangedField('path')) { @@ -81,9 +80,8 @@ class AttachmentDeleteListener /** * Ensure that attachments are not used in preview, so that they can be deleted (without integrity violation). - * - * @ORM\PreRemove() */ + #[ORM\PreRemove] public function preRemoveHandler(Attachment $attachment, PreRemoveEventArgs $event): void { //Ensure that the attachment that will be deleted, is not used as preview picture anymore... @@ -109,9 +107,8 @@ class AttachmentDeleteListener /** * Removes the file associated with the attachment, after the attachment was deleted. - * - * @PostRemove */ + #[PostRemove] public function postRemoveHandler(Attachment $attachment, PostRemoveEventArgs $event): void { //Dont delete file if the attachment uses a builtin ressource: diff --git a/src/EntityListeners/TreeCacheInvalidationListener.php b/src/EntityListeners/TreeCacheInvalidationListener.php index 017c8018..6e17fe3f 100644 --- a/src/EntityListeners/TreeCacheInvalidationListener.php +++ b/src/EntityListeners/TreeCacheInvalidationListener.php @@ -44,11 +44,9 @@ class TreeCacheInvalidationListener $this->keyGenerator = $keyGenerator; } - /** - * @ORM\PostUpdate() - * @ORM\PostPersist() - * @ORM\PostRemove() - */ + #[ORM\PostUpdate] + #[ORM\PostPersist] + #[ORM\PostRemove] public function invalidate(AbstractDBElement $element, LifecycleEventArgs $event): void { //If an element was changed, then invalidate all cached trees with this element class