Started to move doctrine annotations to attributes (rector automated)

This commit is contained in:
Jan Böhmer 2023-05-28 01:33:45 +02:00
parent bb1285c35c
commit 0bc4699cdc
73 changed files with 483 additions and 604 deletions

View file

@ -4,6 +4,7 @@ declare(strict_types=1);
use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector; use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
use Rector\Config\RectorConfig; use Rector\Config\RectorConfig;
use Rector\Doctrine\Set\DoctrineSetList;
use Rector\Set\ValueObject\LevelSetList; use Rector\Set\ValueObject\LevelSetList;
use Rector\Set\ValueObject\SetList; use Rector\Set\ValueObject\SetList;
use Rector\Symfony\Set\SymfonyLevelSetList; use Rector\Symfony\Set\SymfonyLevelSetList;
@ -25,10 +26,16 @@ return static function (RectorConfig $rectorConfig): void {
// define sets of rules // define sets of rules
$rectorConfig->sets([ $rectorConfig->sets([
//PHP rules
//SetList::CODE_QUALITY, //SetList::CODE_QUALITY,
//LevelSetList::UP_TO_PHP_81, //LevelSetList::UP_TO_PHP_81,
//Symfony rules
SymfonyLevelSetList::UP_TO_SYMFONY_62, SymfonyLevelSetList::UP_TO_SYMFONY_62,
//SymfonySetList::ANNOTATIONS_TO_ATTRIBUTES,
SymfonySetList::SYMFONY_CODE_QUALITY, SymfonySetList::SYMFONY_CODE_QUALITY,
//Doctrine rules
DoctrineSetList::ANNOTATIONS_TO_ATTRIBUTES,
DoctrineSetList::DOCTRINE_CODE_QUALITY,
]); ]);
}; };

View file

@ -33,27 +33,17 @@ use LogicException;
/** /**
* Class Attachment. * 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 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 * @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; protected ?string $original_filename = null;
/** /**
* @var string The path to the file relative to a placeholder path like %MEDIA% * @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 = ''; protected string $path = '';
/** /**
* @var string the name of this element * @var string the name of this element
* @ORM\Column(type="string")
*/ */
#[Assert\NotBlank(message: 'validator.attachment.name_not_blank')] #[Assert\NotBlank(message: 'validator.attachment.name_not_blank')]
#[Groups(['simple', 'extended', 'full'])] #[Groups(['simple', 'extended', 'full'])]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING)]
protected string $name = ''; protected string $name = '';
/** /**
@ -111,17 +101,17 @@ abstract class Attachment extends AbstractNamedDBElement
/** /**
* @var bool * @var bool
* @ORM\Column(type="boolean")
*/ */
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN)]
protected bool $show_in_table = false; protected bool $show_in_table = false;
/** /**
* @var AttachmentType|null * @var AttachmentType|null
* @ORM\ManyToOne(targetEntity="AttachmentType", inversedBy="attachments_with_type")
* @ORM\JoinColumn(name="type_id", referencedColumnName="id", nullable=false)
* @Selectable() * @Selectable()
*/ */
#[Assert\NotNull(message: 'validator.attachment.must_not_be_null')] #[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; protected ?AttachmentType $attachment_type = null;
public function __construct() public function __construct()

View file

@ -31,9 +31,7 @@ use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups; use Symfony\Component\Serializer\Annotation\Groups;
/** #[ORM\MappedSuperclass]
* @ORM\MappedSuperclass()
*/
abstract class AttachmentContainingDBElement extends AbstractNamedDBElement implements HasMasterAttachmentInterface, HasAttachmentsInterface abstract class AttachmentContainingDBElement extends AbstractNamedDBElement implements HasMasterAttachmentInterface, HasAttachmentsInterface
{ {
use MasterAttachmentTrait; use MasterAttachmentTrait;

View file

@ -32,56 +32,52 @@ use Symfony\Component\Validator\Constraints as Assert;
/** /**
* Class AttachmentType. * 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 class AttachmentType extends AbstractStructuralDBElement
{ {
/** #[ORM\OneToMany(targetEntity: 'AttachmentType', mappedBy: 'parent', cascade: ['persist'])]
* @ORM\OneToMany(targetEntity="AttachmentType", mappedBy="parent", cascade={"persist"}) #[ORM\OrderBy(['name' => 'ASC'])]
* @ORM\OrderBy({"name" = "ASC"})
*/
protected Collection $children; protected Collection $children;
/** #[ORM\ManyToOne(targetEntity: 'AttachmentType', inversedBy: 'children')]
* @ORM\ManyToOne(targetEntity="AttachmentType", inversedBy="children") #[ORM\JoinColumn(name: 'parent_id')]
* @ORM\JoinColumn(name="parent_id", referencedColumnName="id")
*/
protected ?AbstractStructuralDBElement $parent; protected ?AbstractStructuralDBElement $parent;
/** /**
* @var string * @var string
* @ORM\Column(type="text")
* @ValidFileFilter * @ValidFileFilter
*/ */
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT)]
protected string $filetype_filter = ''; protected string $filetype_filter = '';
/** /**
* @var Collection<int, AttachmentTypeAttachment> * @var Collection<int, AttachmentTypeAttachment>
* @ORM\OneToMany(targetEntity="App\Entity\Attachments\AttachmentTypeAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
* @ORM\OrderBy({"name" = "ASC"})
*/ */
#[Assert\Valid] #[Assert\Valid]
#[ORM\OneToMany(targetEntity: 'App\Entity\Attachments\AttachmentTypeAttachment', mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
#[ORM\OrderBy(['name' => 'ASC'])]
protected Collection $attachments; protected Collection $attachments;
/** @var Collection<int, AttachmentTypeParameter> /** @var Collection<int, AttachmentTypeParameter>
* @ORM\OneToMany(targetEntity="App\Entity\Parameters\AttachmentTypeParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
* @ORM\OrderBy({"group" = "ASC" ,"name" = "ASC"})
*/ */
#[Assert\Valid] #[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; protected Collection $parameters;
/** /**
* @var Collection<int, Attachment> * @var \Doctrine\Common\Collections\Collection<\App\Entity\Attachments\Attachment>
* @ORM\OneToMany(targetEntity="Attachment", mappedBy="attachment_type")
*/ */
protected $attachments_with_type; #[ORM\OneToMany(targetEntity: 'Attachment', mappedBy: 'attachment_type')]
protected \Doctrine\Common\Collections\Collection $attachments_with_type;
public function __construct() public function __construct()
{ {
$this->children = new \Doctrine\Common\Collections\ArrayCollection();
$this->parameters = new \Doctrine\Common\Collections\ArrayCollection();
parent::__construct(); parent::__construct();
$this->attachments = new ArrayCollection(); $this->attachments = new ArrayCollection();
$this->attachments_with_type = new ArrayCollection(); $this->attachments_with_type = new ArrayCollection();

View file

@ -27,17 +27,16 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/** /**
* A attachment attached to an attachmentType element. * A attachment attached to an attachmentType element.
*
* @ORM\Entity()
*/ */
#[UniqueEntity(['name', 'attachment_type', 'element'])] #[UniqueEntity(['name', 'attachment_type', 'element'])]
#[ORM\Entity]
class AttachmentTypeAttachment extends Attachment class AttachmentTypeAttachment extends Attachment
{ {
public const ALLOWED_ELEMENT_CLASS = AttachmentType::class; public const ALLOWED_ELEMENT_CLASS = AttachmentType::class;
/** /**
* @var AttachmentContainingDBElement|null the element this attachment is associated with * @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; protected ?AttachmentContainingDBElement $element = null;
} }

View file

@ -28,17 +28,16 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/** /**
* An attachment attached to a category element. * An attachment attached to a category element.
*
* @ORM\Entity()
*/ */
#[UniqueEntity(['name', 'attachment_type', 'element'])] #[UniqueEntity(['name', 'attachment_type', 'element'])]
#[ORM\Entity]
class CategoryAttachment extends Attachment class CategoryAttachment extends Attachment
{ {
public const ALLOWED_ELEMENT_CLASS = Category::class; public const ALLOWED_ELEMENT_CLASS = Category::class;
/** /**
* @var AttachmentContainingDBElement|null the element this attachment is associated with * @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; protected ?AttachmentContainingDBElement $element = null;
} }

View file

@ -28,17 +28,16 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/** /**
* An attachment attached to a currency element. * An attachment attached to a currency element.
*
* @ORM\Entity()
*/ */
#[UniqueEntity(['name', 'attachment_type', 'element'])] #[UniqueEntity(['name', 'attachment_type', 'element'])]
#[ORM\Entity]
class CurrencyAttachment extends Attachment class CurrencyAttachment extends Attachment
{ {
public const ALLOWED_ELEMENT_CLASS = Currency::class; public const ALLOWED_ELEMENT_CLASS = Currency::class;
/** /**
* @var Currency|null the element this attachment is associated with * @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; protected ?AttachmentContainingDBElement $element = null;
} }

View file

@ -28,17 +28,16 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/** /**
* An attachment attached to a footprint element. * An attachment attached to a footprint element.
*
* @ORM\Entity()
*/ */
#[UniqueEntity(['name', 'attachment_type', 'element'])] #[UniqueEntity(['name', 'attachment_type', 'element'])]
#[ORM\Entity]
class FootprintAttachment extends Attachment class FootprintAttachment extends Attachment
{ {
public const ALLOWED_ELEMENT_CLASS = Footprint::class; public const ALLOWED_ELEMENT_CLASS = Footprint::class;
/** /**
* @var Footprint|null the element this attachment is associated with * @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; protected ?AttachmentContainingDBElement $element = null;
} }

View file

@ -28,18 +28,17 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/** /**
* An attachment attached to a Group element. * An attachment attached to a Group element.
*
* @ORM\Entity()
*/ */
#[UniqueEntity(['name', 'attachment_type', 'element'])] #[UniqueEntity(['name', 'attachment_type', 'element'])]
#[ORM\Entity]
class GroupAttachment extends Attachment class GroupAttachment extends Attachment
{ {
public const ALLOWED_ELEMENT_CLASS = Group::class; public const ALLOWED_ELEMENT_CLASS = Group::class;
/** /**
* @var Group|null the element this attachment is associated with * @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; protected ?AttachmentContainingDBElement $element = null;
} }

View file

@ -47,18 +47,17 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/** /**
* A attachment attached to a user element. * A attachment attached to a user element.
*
* @ORM\Entity()
*/ */
#[UniqueEntity(['name', 'attachment_type', 'element'])] #[UniqueEntity(['name', 'attachment_type', 'element'])]
#[ORM\Entity]
class LabelAttachment extends Attachment class LabelAttachment extends Attachment
{ {
public const ALLOWED_ELEMENT_CLASS = LabelProfile::class; public const ALLOWED_ELEMENT_CLASS = LabelProfile::class;
/** /**
* @var LabelProfile the element this attachment is associated with * @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; protected ?AttachmentContainingDBElement $element = null;
} }

View file

@ -28,18 +28,17 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/** /**
* An attachment attached to a manufacturer element. * An attachment attached to a manufacturer element.
*
* @ORM\Entity()
*/ */
#[UniqueEntity(['name', 'attachment_type', 'element'])] #[UniqueEntity(['name', 'attachment_type', 'element'])]
#[ORM\Entity]
class ManufacturerAttachment extends Attachment class ManufacturerAttachment extends Attachment
{ {
public const ALLOWED_ELEMENT_CLASS = Manufacturer::class; public const ALLOWED_ELEMENT_CLASS = Manufacturer::class;
/** /**
* @var Manufacturer|null the element this attachment is associated with * @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; protected ?AttachmentContainingDBElement $element = null;
} }

View file

@ -29,17 +29,16 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/** /**
* An attachment attached to a measurement unit element. * An attachment attached to a measurement unit element.
*
* @ORM\Entity()
*/ */
#[UniqueEntity(['name', 'attachment_type', 'element'])] #[UniqueEntity(['name', 'attachment_type', 'element'])]
#[ORM\Entity]
class MeasurementUnitAttachment extends Attachment class MeasurementUnitAttachment extends Attachment
{ {
public const ALLOWED_ELEMENT_CLASS = MeasurementUnit::class; public const ALLOWED_ELEMENT_CLASS = MeasurementUnit::class;
/** /**
* @var Manufacturer|null the element this attachment is associated with * @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; protected ?AttachmentContainingDBElement $element = null;
} }

View file

@ -28,17 +28,16 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/** /**
* A attachment attached to a part element. * A attachment attached to a part element.
*
* @ORM\Entity()
*/ */
#[UniqueEntity(['name', 'attachment_type', 'element'])] #[UniqueEntity(['name', 'attachment_type', 'element'])]
#[ORM\Entity]
class PartAttachment extends Attachment class PartAttachment extends Attachment
{ {
public const ALLOWED_ELEMENT_CLASS = Part::class; public const ALLOWED_ELEMENT_CLASS = Part::class;
/** /**
* @var Part the element this attachment is associated with * @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; protected ?AttachmentContainingDBElement $element = null;
} }

View file

@ -28,17 +28,16 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/** /**
* A attachment attached to a device element. * A attachment attached to a device element.
*
* @ORM\Entity()
*/ */
#[UniqueEntity(['name', 'attachment_type', 'element'])] #[UniqueEntity(['name', 'attachment_type', 'element'])]
#[ORM\Entity]
class ProjectAttachment extends Attachment class ProjectAttachment extends Attachment
{ {
public const ALLOWED_ELEMENT_CLASS = Project::class; public const ALLOWED_ELEMENT_CLASS = Project::class;
/** /**
* @var Project|null the element this attachment is associated with * @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; protected ?AttachmentContainingDBElement $element = null;
} }

View file

@ -28,18 +28,17 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/** /**
* An attachment attached to a measurement unit element. * An attachment attached to a measurement unit element.
*
* @ORM\Entity()
*/ */
#[UniqueEntity(['name', 'attachment_type', 'element'])] #[UniqueEntity(['name', 'attachment_type', 'element'])]
#[ORM\Entity]
class StorelocationAttachment extends Attachment class StorelocationAttachment extends Attachment
{ {
public const ALLOWED_ELEMENT_CLASS = Storelocation::class; public const ALLOWED_ELEMENT_CLASS = Storelocation::class;
/** /**
* @var Storelocation|null the element this attachment is associated with * @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; protected ?AttachmentContainingDBElement $element = null;
} }

View file

@ -28,18 +28,17 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/** /**
* A attachment attached to a supplier element. * A attachment attached to a supplier element.
*
* @ORM\Entity()
*/ */
#[UniqueEntity(['name', 'attachment_type', 'element'])] #[UniqueEntity(['name', 'attachment_type', 'element'])]
#[ORM\Entity]
class SupplierAttachment extends Attachment class SupplierAttachment extends Attachment
{ {
public const ALLOWED_ELEMENT_CLASS = Supplier::class; public const ALLOWED_ELEMENT_CLASS = Supplier::class;
/** /**
* @var Supplier|null the element this attachment is associated with * @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; protected ?AttachmentContainingDBElement $element = null;
} }

View file

@ -28,18 +28,17 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/** /**
* An attachment attached to a user element. * An attachment attached to a user element.
*
* @ORM\Entity()
*/ */
#[UniqueEntity(['name', 'attachment_type', 'element'])] #[UniqueEntity(['name', 'attachment_type', 'element'])]
#[ORM\Entity]
class UserAttachment extends Attachment class UserAttachment extends Attachment
{ {
public const ALLOWED_ELEMENT_CLASS = User::class; public const ALLOWED_ELEMENT_CLASS = User::class;
/** /**
* @var User|null the element this attachment is associated with * @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; protected ?AttachmentContainingDBElement $element = null;
} }

View file

@ -29,52 +29,51 @@ use Symfony\Component\Validator\Constraints as Assert;
/** /**
* This abstract class is used for companies like suppliers or manufacturers. * This abstract class is used for companies like suppliers or manufacturers.
*
* @ORM\MappedSuperclass()
*/ */
#[ORM\MappedSuperclass]
abstract class AbstractCompany extends AbstractPartsContainingDBElement abstract class AbstractCompany extends AbstractPartsContainingDBElement
{ {
/** /**
* @var string The address of the company * @var string The address of the company
* @ORM\Column(type="string")
*/ */
#[Groups(['full'])] #[Groups(['full'])]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING)]
protected string $address = ''; protected string $address = '';
/** /**
* @var string The phone number of the company * @var string The phone number of the company
* @ORM\Column(type="string")
*/ */
#[Groups(['full'])] #[Groups(['full'])]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING)]
protected string $phone_number = ''; protected string $phone_number = '';
/** /**
* @var string The fax number of the company * @var string The fax number of the company
* @ORM\Column(type="string")
*/ */
#[Groups(['full'])] #[Groups(['full'])]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING)]
protected string $fax_number = ''; protected string $fax_number = '';
/** /**
* @var string The email address of the company * @var string The email address of the company
* @ORM\Column(type="string")
*/ */
#[Assert\Email] #[Assert\Email]
#[Groups(['full'])] #[Groups(['full'])]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING)]
protected string $email_address = ''; protected string $email_address = '';
/** /**
* @var string The website of the company * @var string The website of the company
* @ORM\Column(type="string")
*/ */
#[Assert\Url] #[Assert\Url]
#[Groups(['full'])] #[Groups(['full'])]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING)]
protected string $website = ''; protected string $website = '';
/** /**
* @var string * @var string
* @ORM\Column(type="string")
*/ */
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING)]
protected string $auto_product_url = ''; protected string $auto_product_url = '';
/******************************************************************************** /********************************************************************************

View file

@ -34,19 +34,18 @@ use Symfony\Component\Serializer\Annotation\Groups;
* (except special tables like "internal"...) * (except special tables like "internal"...)
* Every database table which are managed with this class (or a subclass of it) * 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. * 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'])] #[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 abstract class AbstractDBElement implements JsonSerializable
{ {
/** @var int|null The Identification number for this part. This value is unique for the element in this table. /** @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. * Null if the element is not saved to DB yet.
* @ORM\Column(type="integer")
* @ORM\Id()
* @ORM\GeneratedValue()
*/ */
#[Groups(['full'])] #[Groups(['full'])]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER)]
#[ORM\Id]
#[ORM\GeneratedValue]
protected ?int $id = null; protected ?int $id = null;
public function __clone() public function __clone()

View file

@ -30,20 +30,19 @@ use Symfony\Component\Validator\Constraints as Assert;
/** /**
* All subclasses of this class have an attribute "name". * 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 abstract class AbstractNamedDBElement extends AbstractDBElement implements NamedElementInterface, TimeStampableInterface
{ {
use TimestampTrait; use TimestampTrait;
/** /**
* @var string the name of this element * @var string the name of this element
* @ORM\Column(type="string")
*/ */
#[Assert\NotBlank] #[Assert\NotBlank]
#[Groups(['simple', 'extended', 'full', 'import'])] #[Groups(['simple', 'extended', 'full', 'import'])]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING)]
protected string $name = ''; protected string $name = '';
/****************************************************************************** /******************************************************************************

View file

@ -28,9 +28,8 @@ use Symfony\Component\Serializer\Annotation\Groups;
/** /**
* Class PartsContainingDBElement. * Class PartsContainingDBElement.
*
* @ORM\MappedSuperclass(repositoryClass="App\Repository\AbstractPartsContainingRepository")
*/ */
#[ORM\MappedSuperclass(repositoryClass: 'App\Repository\AbstractPartsContainingRepository')]
abstract class AbstractPartsContainingDBElement extends AbstractStructuralDBElement abstract class AbstractPartsContainingDBElement extends AbstractStructuralDBElement
{ {
#[Groups(['full'])] #[Groups(['full'])]

View file

@ -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 * 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! * 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')] #[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 abstract class AbstractStructuralDBElement extends AttachmentContainingDBElement
{ {
use ParametersTrait; use ParametersTrait;
@ -61,17 +61,17 @@ abstract class AbstractStructuralDBElement extends AttachmentContainingDBElement
/** /**
* @var string The comment info for this element * @var string The comment info for this element
* @ORM\Column(type="text")
*/ */
#[Groups(['full', 'import'])] #[Groups(['full', 'import'])]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT)]
protected string $comment = ''; protected string $comment = '';
/** /**
* @var bool If this property is set, this element can not be selected for part properties. * @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. * Useful if this element should be used only for grouping, sorting.
* @ORM\Column(type="boolean")
*/ */
#[Groups(['full', 'import'])] #[Groups(['full', 'import'])]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN)]
protected bool $not_selectable = false; protected bool $not_selectable = false;
/** /**

View file

@ -33,10 +33,10 @@ trait MasterAttachmentTrait
{ {
/** /**
* @var Attachment|null * @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')] #[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; protected ?Attachment $master_picture_attachment = null;
/** /**

View file

@ -44,9 +44,7 @@ namespace App\Entity\LabelSystem;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\Validator\Constraints as Assert;
/** #[ORM\Embeddable]
* @ORM\Embeddable()
*/
class LabelOptions class LabelOptions
{ {
public const BARCODE_TYPES = ['none', /*'ean8',*/ 'qr', 'code39', 'datamatrix', 'code93', 'code128']; 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 * @var float The page size of the label in mm
* @ORM\Column(type="float")
*/ */
#[Assert\Positive] #[Assert\Positive]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::FLOAT)]
protected float $width = 50.0; protected float $width = 50.0;
/** /**
* @var float The page size of the label in mm * @var float The page size of the label in mm
* @ORM\Column(type="float")
*/ */
#[Assert\Positive] #[Assert\Positive]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::FLOAT)]
protected float $height = 30.0; protected float $height = 30.0;
/** /**
* @var string The type of the barcode that should be used in the label (e.g. 'qr') * @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)] #[Assert\Choice(choices: LabelOptions::BARCODE_TYPES)]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING)]
protected string $barcode_type = 'none'; protected string $barcode_type = 'none';
/** /**
* @var string What image should be shown along the * @var string What image should be shown along the
* @ORM\Column(type="string")
*/ */
#[Assert\Choice(choices: LabelOptions::PICTURE_TYPES)] #[Assert\Choice(choices: LabelOptions::PICTURE_TYPES)]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING)]
protected string $picture_type = 'none'; protected string $picture_type = 'none';
/** /**
* @var string * @var string
* @ORM\Column(type="string")
*/ */
#[Assert\Choice(choices: LabelOptions::SUPPORTED_ELEMENTS)] #[Assert\Choice(choices: LabelOptions::SUPPORTED_ELEMENTS)]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING)]
protected string $supported_element = 'part'; protected string $supported_element = 'part';
/** /**
* @var string any additional CSS for the label * @var string any additional CSS for the label
* @ORM\Column(type="text")
*/ */
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT)]
protected string $additional_css = ''; protected string $additional_css = '';
/** @var string The mode that will be used to interpret the lines /** @var string The mode that will be used to interpret the lines
* @ORM\Column(type="string")
*/ */
#[Assert\Choice(choices: LabelOptions::LINES_MODES)] #[Assert\Choice(choices: LabelOptions::LINES_MODES)]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING)]
protected string $lines_mode = 'html'; protected string $lines_mode = 'html';
/** /**
* @var string * @var string
* @ORM\Column(type="text")
*/ */
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT)]
protected string $lines = ''; protected string $lines = '';
public function getWidth(): float public function getWidth(): float

View file

@ -48,42 +48,41 @@ use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Validator\Constraints as Assert; 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'])] #[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 class LabelProfile extends AttachmentContainingDBElement
{ {
/** /**
* @var Collection<int, LabelAttachment> * @var Collection<int, LabelAttachment>
* @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; protected Collection $attachments;
/** /**
* @var LabelOptions * @var LabelOptions
* @ORM\Embedded(class="LabelOptions")
*/ */
#[Assert\Valid] #[Assert\Valid]
#[ORM\Embedded(class: 'LabelOptions')]
protected LabelOptions $options; protected LabelOptions $options;
/** /**
* @var string The comment info for this element * @var string The comment info for this element
* @ORM\Column(type="text")
*/ */
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT)]
protected string $comment = ''; protected string $comment = '';
/** /**
* @var bool determines, if this label profile should be shown in the dropdown quick menu * @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; protected bool $show_in_dropdown = true;
public function __construct() public function __construct()
{ {
$this->attachments = new \Doctrine\Common\Collections\ArrayCollection();
parent::__construct(); parent::__construct();
$this->options = new LabelOptions(); $this->options = new LabelOptions();
} }

View file

@ -84,11 +84,7 @@ use App\Entity\UserSystem\User;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use InvalidArgumentException; use InvalidArgumentException;
/** #[ORM\Entity]
* @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.
*/
class CollectionElementDeleted extends AbstractLogEntry implements LogWithEventUndoInterface class CollectionElementDeleted extends AbstractLogEntry implements LogWithEventUndoInterface
{ {
protected string $typeString = 'collection_element_deleted'; protected string $typeString = 'collection_element_deleted';

View file

@ -25,9 +25,7 @@ namespace App\Entity\LogSystem;
use App\Exceptions\LogEntryObsoleteException; use App\Exceptions\LogEntryObsoleteException;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
/** #[ORM\Entity]
* @ORM\Entity()
*/
class ConfigChangedLogEntry extends AbstractLogEntry class ConfigChangedLogEntry extends AbstractLogEntry
{ {
protected string $typeString = 'config_changed'; protected string $typeString = 'config_changed';

View file

@ -24,9 +24,7 @@ namespace App\Entity\LogSystem;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
/** #[ORM\Entity]
* @ORM\Entity()
*/
class DatabaseUpdatedLogEntry extends AbstractLogEntry class DatabaseUpdatedLogEntry extends AbstractLogEntry
{ {
protected string $typeString = 'database_updated'; protected string $typeString = 'database_updated';

View file

@ -30,9 +30,7 @@ use App\Entity\UserSystem\User;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use InvalidArgumentException; use InvalidArgumentException;
/** #[ORM\Entity]
* @ORM\Entity()
*/
class ElementCreatedLogEntry extends AbstractLogEntry implements LogWithCommentInterface, LogWithEventUndoInterface class ElementCreatedLogEntry extends AbstractLogEntry implements LogWithCommentInterface, LogWithEventUndoInterface
{ {
protected string $typeString = 'element_created'; protected string $typeString = 'element_created';

View file

@ -32,9 +32,7 @@ use App\Entity\UserSystem\User;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use InvalidArgumentException; use InvalidArgumentException;
/** #[ORM\Entity]
* @ORM\Entity()
*/
class ElementDeletedLogEntry extends AbstractLogEntry implements TimeTravelInterface, LogWithCommentInterface, LogWithEventUndoInterface class ElementDeletedLogEntry extends AbstractLogEntry implements TimeTravelInterface, LogWithCommentInterface, LogWithEventUndoInterface
{ {
protected string $typeString = 'element_deleted'; protected string $typeString = 'element_deleted';

View file

@ -30,9 +30,7 @@ use App\Entity\Contracts\TimeTravelInterface;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use InvalidArgumentException; use InvalidArgumentException;
/** #[ORM\Entity]
* @ORM\Entity()
*/
class ElementEditedLogEntry extends AbstractLogEntry implements TimeTravelInterface, LogWithCommentInterface, LogWithEventUndoInterface, LogWithNewDataInterface class ElementEditedLogEntry extends AbstractLogEntry implements TimeTravelInterface, LogWithCommentInterface, LogWithEventUndoInterface, LogWithNewDataInterface
{ {
protected string $typeString = 'element_edited'; protected string $typeString = 'element_edited';

View file

@ -25,9 +25,7 @@ namespace App\Entity\LogSystem;
use App\Exceptions\LogEntryObsoleteException; use App\Exceptions\LogEntryObsoleteException;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
/** #[ORM\Entity]
* @ORM\Entity()
*/
class ExceptionLogEntry extends AbstractLogEntry class ExceptionLogEntry extends AbstractLogEntry
{ {
protected string $typeString = 'exception'; protected string $typeString = 'exception';

View file

@ -24,9 +24,7 @@ namespace App\Entity\LogSystem;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
/** #[ORM\Entity]
* @ORM\Entity()
*/
class LegacyInstockChangedLogEntry extends AbstractLogEntry class LegacyInstockChangedLogEntry extends AbstractLogEntry
{ {
protected string $typeString = 'instock_changed'; protected string $typeString = 'instock_changed';

View file

@ -23,9 +23,7 @@ namespace App\Entity\LogSystem;
use App\Entity\Parts\PartLot; use App\Entity\Parts\PartLot;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
/** #[ORM\Entity]
* @ORM\Entity()
*/
class PartStockChangedLogEntry extends AbstractLogEntry class PartStockChangedLogEntry extends AbstractLogEntry
{ {
public const TYPE_ADD = "add"; public const TYPE_ADD = "add";

View file

@ -50,9 +50,8 @@ use Symfony\Component\HttpFoundation\IpUtils;
/** /**
* This log entry is created when something security related to a user happens. * This log entry is created when something security related to a user happens.
*
* @ORM\Entity()
*/ */
#[ORM\Entity]
class SecurityEventLogEntry extends AbstractLogEntry class SecurityEventLogEntry extends AbstractLogEntry
{ {
public const SECURITY_TYPE_MAPPING = [ public const SECURITY_TYPE_MAPPING = [

View file

@ -27,9 +27,8 @@ use Symfony\Component\HttpFoundation\IpUtils;
/** /**
* This log entry is created when a user logs in. * This log entry is created when a user logs in.
*
* @ORM\Entity()
*/ */
#[ORM\Entity]
class UserLoginLogEntry extends AbstractLogEntry class UserLoginLogEntry extends AbstractLogEntry
{ {
protected string $typeString = 'user_login'; protected string $typeString = 'user_login';

View file

@ -25,9 +25,7 @@ namespace App\Entity\LogSystem;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\HttpFoundation\IpUtils; use Symfony\Component\HttpFoundation\IpUtils;
/** #[ORM\Entity]
* @ORM\Entity()
*/
class UserLogoutLogEntry extends AbstractLogEntry class UserLogoutLogEntry extends AbstractLogEntry
{ {
protected string $typeString = 'user_logout'; protected string $typeString = 'user_logout';

View file

@ -24,9 +24,7 @@ namespace App\Entity\LogSystem;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
/** #[ORM\Entity]
* @ORM\Entity()
*/
class UserNotAllowedLogEntry extends AbstractLogEntry class UserNotAllowedLogEntry extends AbstractLogEntry
{ {
protected string $typeString = 'user_not_allowed'; protected string $typeString = 'user_not_allowed';

View file

@ -51,29 +51,14 @@ use Symfony\Component\Validator\Constraints as Assert;
use function sprintf; use function sprintf;
/** #[ORM\Entity(repositoryClass: 'App\Repository\ParameterRepository')]
* @ORM\Entity(repositoryClass="App\Repository\ParameterRepository") #[ORM\InheritanceType('SINGLE_TABLE')]
* @ORM\Table("parameters", indexes={ #[ORM\DiscriminatorColumn(name: 'type', type: 'smallint')]
* @ORM\Index(name="parameter_name_idx", columns={"name"}), #[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\Index(name="parameter_group_idx", columns={"param_group"}), #[ORM\Table('parameters')]
* @ORM\Index(name="parameter_type_element_idx", columns={"type", "element_id"}) #[ORM\Index(name: 'parameter_name_idx', columns: ['name'])]
* }) #[ORM\Index(name: 'parameter_group_idx', columns: ['param_group'])]
* @ORM\InheritanceType("SINGLE_TABLE") #[ORM\Index(name: 'parameter_type_element_idx', columns: ['type', 'element_id'])]
* @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"
* })
*/
abstract class AbstractParameter extends AbstractNamedDBElement 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 * @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)] #[Assert\Length(max: 20)]
#[Groups(['full'])] #[Groups(['full'])]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING)]
protected string $symbol = ''; protected string $symbol = '';
/** /**
* @var float|null the guaranteed minimum value of this property * @var float|null the guaranteed minimum value of this property
* @ORM\Column(type="float", nullable=true)
*/ */
#[Assert\Type(['float', null])] #[Assert\Type(['float', null])]
#[Assert\LessThanOrEqual(propertyPath: 'value_typical', message: 'parameters.validator.min_lesser_typical')] #[Assert\LessThanOrEqual(propertyPath: 'value_typical', message: 'parameters.validator.min_lesser_typical')]
#[Assert\LessThan(propertyPath: 'value_max', message: 'parameters.validator.min_lesser_max')] #[Assert\LessThan(propertyPath: 'value_max', message: 'parameters.validator.min_lesser_max')]
#[Groups(['full'])] #[Groups(['full'])]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::FLOAT, nullable: true)]
protected ?float $value_min = null; protected ?float $value_min = null;
/** /**
* @var float|null the typical value of this property * @var float|null the typical value of this property
* @ORM\Column(type="float", nullable=true)
*/ */
#[Assert\Type([null, 'float'])] #[Assert\Type([null, 'float'])]
#[Groups(['full'])] #[Groups(['full'])]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::FLOAT, nullable: true)]
protected ?float $value_typical = null; protected ?float $value_typical = null;
/** /**
* @var float|null the maximum value of this property * @var float|null the maximum value of this property
* @ORM\Column(type="float", nullable=true)
*/ */
#[Assert\Type(['float', null])] #[Assert\Type(['float', null])]
#[Assert\GreaterThanOrEqual(propertyPath: 'value_typical', message: 'parameters.validator.max_greater_typical')] #[Assert\GreaterThanOrEqual(propertyPath: 'value_typical', message: 'parameters.validator.max_greater_typical')]
#[Groups(['full'])] #[Groups(['full'])]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::FLOAT, nullable: true)]
protected ?float $value_max = null; protected ?float $value_max = null;
/** /**
* @var string The unit in which the value values are given (e.g. V) * @var string The unit in which the value values are given (e.g. V)
* @ORM\Column(type="string", nullable=false)
*/ */
#[Groups(['full'])] #[Groups(['full'])]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING)]
protected string $unit = ''; protected string $unit = '';
/** /**
* @var string a text value for the given property * @var string a text value for the given property
* @ORM\Column(type="string", nullable=false)
*/ */
#[Groups(['full'])] #[Groups(['full'])]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING)]
protected string $value_text = ''; protected string $value_text = '';
/** /**
* @var string the group this parameter belongs to * @var string the group this parameter belongs to
* @ORM\Column(type="string", nullable=false, name="param_group")
*/ */
#[Groups(['full'])] #[Groups(['full'])]
#[Groups(['full'])] #[Groups(['full'])]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, name: 'param_group')]
protected string $group = ''; protected string $group = '';
/** /**

View file

@ -46,17 +46,15 @@ use App\Entity\Base\AbstractDBElement;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* @ORM\Entity(repositoryClass="App\Repository\ParameterRepository")
*/
#[UniqueEntity(fields: ['name', 'group', 'element'])] #[UniqueEntity(fields: ['name', 'group', 'element'])]
#[ORM\Entity(repositoryClass: 'App\Repository\ParameterRepository')]
class AttachmentTypeParameter extends AbstractParameter class AttachmentTypeParameter extends AbstractParameter
{ {
public const ALLOWED_ELEMENT_CLASS = AttachmentType::class; public const ALLOWED_ELEMENT_CLASS = AttachmentType::class;
/** /**
* @var AttachmentType the element this para is associated with * @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; protected ?AbstractDBElement $element = null;
} }

View file

@ -46,17 +46,15 @@ use App\Entity\Parts\Category;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* @ORM\Entity(repositoryClass="App\Repository\ParameterRepository")
*/
#[UniqueEntity(fields: ['name', 'group', 'element'])] #[UniqueEntity(fields: ['name', 'group', 'element'])]
#[ORM\Entity(repositoryClass: 'App\Repository\ParameterRepository')]
class CategoryParameter extends AbstractParameter class CategoryParameter extends AbstractParameter
{ {
public const ALLOWED_ELEMENT_CLASS = Category::class; public const ALLOWED_ELEMENT_CLASS = Category::class;
/** /**
* @var Category the element this para is associated with * @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; protected ?AbstractDBElement $element = null;
} }

View file

@ -48,18 +48,17 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/** /**
* An attachment attached to a category element. * An attachment attached to a category element.
*
* @ORM\Entity(repositoryClass="App\Repository\ParameterRepository")
*/ */
#[UniqueEntity(fields: ['name', 'group', 'element'])] #[UniqueEntity(fields: ['name', 'group', 'element'])]
#[ORM\Entity(repositoryClass: 'App\Repository\ParameterRepository')]
class CurrencyParameter extends AbstractParameter class CurrencyParameter extends AbstractParameter
{ {
public const ALLOWED_ELEMENT_CLASS = Currency::class; public const ALLOWED_ELEMENT_CLASS = Currency::class;
/** /**
* @var Currency the element this para is associated with * @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; protected ?AbstractDBElement $element = null;
} }

View file

@ -46,18 +46,16 @@ use App\Entity\Parts\Footprint;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* @ORM\Entity(repositoryClass="App\Repository\ParameterRepository")
*/
#[UniqueEntity(fields: ['name', 'group', 'element'])] #[UniqueEntity(fields: ['name', 'group', 'element'])]
#[ORM\Entity(repositoryClass: 'App\Repository\ParameterRepository')]
class FootprintParameter extends AbstractParameter class FootprintParameter extends AbstractParameter
{ {
public const ALLOWED_ELEMENT_CLASS = Footprint::class; public const ALLOWED_ELEMENT_CLASS = Footprint::class;
/** /**
* @var Footprint the element this para is associated with * @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; protected ?AbstractDBElement $element = null;
} }

View file

@ -46,18 +46,16 @@ use App\Entity\UserSystem\Group;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* @ORM\Entity(repositoryClass="App\Repository\ParameterRepository")
*/
#[UniqueEntity(fields: ['name', 'group', 'element'])] #[UniqueEntity(fields: ['name', 'group', 'element'])]
#[ORM\Entity(repositoryClass: 'App\Repository\ParameterRepository')]
class GroupParameter extends AbstractParameter class GroupParameter extends AbstractParameter
{ {
public const ALLOWED_ELEMENT_CLASS = Group::class; public const ALLOWED_ELEMENT_CLASS = Group::class;
/** /**
* @var Group the element this para is associated with * @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; protected ?AbstractDBElement $element = null;
} }

View file

@ -46,18 +46,16 @@ use App\Entity\Parts\Manufacturer;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* @ORM\Entity(repositoryClass="App\Repository\ParameterRepository")
*/
#[UniqueEntity(fields: ['name', 'group', 'element'])] #[UniqueEntity(fields: ['name', 'group', 'element'])]
#[ORM\Entity(repositoryClass: 'App\Repository\ParameterRepository')]
class ManufacturerParameter extends AbstractParameter class ManufacturerParameter extends AbstractParameter
{ {
public const ALLOWED_ELEMENT_CLASS = Manufacturer::class; public const ALLOWED_ELEMENT_CLASS = Manufacturer::class;
/** /**
* @var Manufacturer the element this para is associated with * @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; protected ?AbstractDBElement $element = null;
} }

View file

@ -46,18 +46,16 @@ use App\Entity\Parts\MeasurementUnit;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* @ORM\Entity(repositoryClass="App\Repository\ParameterRepository")
*/
#[UniqueEntity(fields: ['name', 'group', 'element'])] #[UniqueEntity(fields: ['name', 'group', 'element'])]
#[ORM\Entity(repositoryClass: 'App\Repository\ParameterRepository')]
class MeasurementUnitParameter extends AbstractParameter class MeasurementUnitParameter extends AbstractParameter
{ {
public const ALLOWED_ELEMENT_CLASS = MeasurementUnit::class; public const ALLOWED_ELEMENT_CLASS = MeasurementUnit::class;
/** /**
* @var MeasurementUnit the element this para is associated with * @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; protected ?AbstractDBElement $element = null;
} }

View file

@ -46,18 +46,16 @@ use App\Entity\Parts\Part;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* @ORM\Entity(repositoryClass="App\Repository\ParameterRepository")
*/
#[UniqueEntity(fields: ['name', 'group', 'element'])] #[UniqueEntity(fields: ['name', 'group', 'element'])]
#[ORM\Entity(repositoryClass: 'App\Repository\ParameterRepository')]
class PartParameter extends AbstractParameter class PartParameter extends AbstractParameter
{ {
public const ALLOWED_ELEMENT_CLASS = Part::class; public const ALLOWED_ELEMENT_CLASS = Part::class;
/** /**
* @var Part the element this para is associated with * @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; protected ?AbstractDBElement $element = null;
} }

View file

@ -46,18 +46,16 @@ use App\Entity\ProjectSystem\Project;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* @ORM\Entity(repositoryClass="App\Repository\ParameterRepository")
*/
#[UniqueEntity(fields: ['name', 'group', 'element'])] #[UniqueEntity(fields: ['name', 'group', 'element'])]
#[ORM\Entity(repositoryClass: 'App\Repository\ParameterRepository')]
class ProjectParameter extends AbstractParameter class ProjectParameter extends AbstractParameter
{ {
public const ALLOWED_ELEMENT_CLASS = Project::class; public const ALLOWED_ELEMENT_CLASS = Project::class;
/** /**
* @var Project the element this para is associated with * @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; protected ?AbstractDBElement $element = null;
} }

View file

@ -46,18 +46,16 @@ use App\Entity\Parts\Storelocation;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* @ORM\Entity(repositoryClass="App\Repository\ParameterRepository")
*/
#[UniqueEntity(fields: ['name', 'group', 'element'])] #[UniqueEntity(fields: ['name', 'group', 'element'])]
#[ORM\Entity(repositoryClass: 'App\Repository\ParameterRepository')]
class StorelocationParameter extends AbstractParameter class StorelocationParameter extends AbstractParameter
{ {
public const ALLOWED_ELEMENT_CLASS = Storelocation::class; public const ALLOWED_ELEMENT_CLASS = Storelocation::class;
/** /**
* @var Storelocation the element this para is associated with * @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; protected ?AbstractDBElement $element = null;
} }

View file

@ -46,18 +46,16 @@ use App\Entity\Parts\Supplier;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* @ORM\Entity(repositoryClass="App\Repository\ParameterRepository")
*/
#[UniqueEntity(fields: ['name', 'group', 'element'])] #[UniqueEntity(fields: ['name', 'group', 'element'])]
#[ORM\Entity(repositoryClass: 'App\Repository\ParameterRepository')]
class SupplierParameter extends AbstractParameter class SupplierParameter extends AbstractParameter
{ {
public const ALLOWED_ELEMENT_CLASS = Supplier::class; public const ALLOWED_ELEMENT_CLASS = Supplier::class;
/** /**
* @var Supplier the element this para is associated with * @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; protected ?AbstractDBElement $element = null;
} }

View file

@ -33,99 +33,95 @@ use Symfony\Component\Validator\Constraints as Assert;
/** /**
* Class AttachmentType. * 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 class Category extends AbstractPartsContainingDBElement
{ {
/** /**
* @ORM\OneToMany(targetEntity="Category", mappedBy="parent")
* @ORM\OrderBy({"name" = "ASC"})
* @var Collection * @var Collection
*/ */
#[ORM\OneToMany(targetEntity: 'Category', mappedBy: 'parent')]
#[ORM\OrderBy(['name' => 'ASC'])]
protected Collection $children; protected Collection $children;
/** #[ORM\ManyToOne(targetEntity: 'Category', inversedBy: 'children')]
* @ORM\ManyToOne(targetEntity="Category", inversedBy="children") #[ORM\JoinColumn(name: 'parent_id')]
* @ORM\JoinColumn(name="parent_id", referencedColumnName="id")
*/
protected ?AbstractStructuralDBElement $parent = null; protected ?AbstractStructuralDBElement $parent = null;
/** /**
* @var string * @var string
* @ORM\Column(type="text")
*/ */
#[Groups(['full', 'import'])] #[Groups(['full', 'import'])]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT)]
protected string $partname_hint = ''; protected string $partname_hint = '';
/** /**
* @var string * @var string
* @ORM\Column(type="text")
*/ */
#[Groups(['full', 'import'])] #[Groups(['full', 'import'])]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT)]
protected string $partname_regex = ''; protected string $partname_regex = '';
/** /**
* @var bool * @var bool
* @ORM\Column(type="boolean")
*/ */
#[Groups(['full', 'import'])] #[Groups(['full', 'import'])]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN)]
protected bool $disable_footprints = false; protected bool $disable_footprints = false;
/** /**
* @var bool * @var bool
* @ORM\Column(type="boolean")
*/ */
#[Groups(['full', 'import'])] #[Groups(['full', 'import'])]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN)]
protected bool $disable_manufacturers = false; protected bool $disable_manufacturers = false;
/** /**
* @var bool * @var bool
* @ORM\Column(type="boolean")
*/ */
#[Groups(['full', 'import'])] #[Groups(['full', 'import'])]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN)]
protected bool $disable_autodatasheets = false; protected bool $disable_autodatasheets = false;
/** /**
* @var bool * @var bool
* @ORM\Column(type="boolean")
*/ */
#[Groups(['full', 'import'])] #[Groups(['full', 'import'])]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN)]
protected bool $disable_properties = false; protected bool $disable_properties = false;
/** /**
* @var string * @var string
* @ORM\Column(type="text")
*/ */
#[Groups(['full', 'import'])] #[Groups(['full', 'import'])]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT)]
protected string $default_description = ''; protected string $default_description = '';
/** /**
* @var string * @var string
* @ORM\Column(type="text")
*/ */
#[Groups(['full', 'import'])] #[Groups(['full', 'import'])]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT)]
protected string $default_comment = ''; protected string $default_comment = '';
/** /**
* @var Collection<int, CategoryAttachment> * @var Collection<int, CategoryAttachment>
* @ORM\OneToMany(targetEntity="App\Entity\Attachments\CategoryAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
* @ORM\OrderBy({"name" = "ASC"})
*/ */
#[Assert\Valid] #[Assert\Valid]
#[Groups(['full'])] #[Groups(['full'])]
#[ORM\OneToMany(targetEntity: 'App\Entity\Attachments\CategoryAttachment', mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
#[ORM\OrderBy(['name' => 'ASC'])]
protected Collection $attachments; protected Collection $attachments;
/** @var Collection<int, CategoryParameter> /** @var Collection<int, CategoryParameter>
* @ORM\OneToMany(targetEntity="App\Entity\Parameters\CategoryParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
* @ORM\OrderBy({"group" = "ASC" ,"name" = "ASC"})
*/ */
#[Assert\Valid] #[Assert\Valid]
#[Groups(['full'])] #[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; protected Collection $parameters;
public function getPartnameHint(): string public function getPartnameHint(): string
@ -247,4 +243,11 @@ class Category extends AbstractPartsContainingDBElement
return $this; 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();
}
} }

View file

@ -31,48 +31,44 @@ use Symfony\Component\Validator\Constraints as Assert;
/** /**
* Class Footprint. * 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 class Footprint extends AbstractPartsContainingDBElement
{ {
/** #[ORM\ManyToOne(targetEntity: 'Footprint', inversedBy: 'children')]
* @ORM\ManyToOne(targetEntity="Footprint", inversedBy="children") #[ORM\JoinColumn(name: 'parent_id')]
* @ORM\JoinColumn(name="parent_id", referencedColumnName="id")
*/
protected ?\App\Entity\Base\AbstractStructuralDBElement $parent; protected ?\App\Entity\Base\AbstractStructuralDBElement $parent;
/** /**
* @ORM\OneToMany(targetEntity="Footprint", mappedBy="parent")
* @ORM\OrderBy({"name" = "ASC"})
* @var Collection * @var Collection
*/ */
#[ORM\OneToMany(targetEntity: 'Footprint', mappedBy: 'parent')]
#[ORM\OrderBy(['name' => 'ASC'])]
protected Collection $children; protected Collection $children;
/** /**
* @var Collection<int, FootprintAttachment> * @var Collection<int, FootprintAttachment>
* @ORM\OneToMany(targetEntity="App\Entity\Attachments\FootprintAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
* @ORM\OrderBy({"name" = "ASC"})
*/ */
#[Assert\Valid] #[Assert\Valid]
#[ORM\OneToMany(targetEntity: 'App\Entity\Attachments\FootprintAttachment', mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
#[ORM\OrderBy(['name' => 'ASC'])]
protected Collection $attachments; protected Collection $attachments;
/** /**
* @var FootprintAttachment|null * @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; protected ?FootprintAttachment $footprint_3d = null;
/** @var Collection<int, FootprintParameter> /** @var Collection<int, FootprintParameter>
* @ORM\OneToMany(targetEntity="App\Entity\Parameters\FootprintParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
* @ORM\OrderBy({"group" = "ASC" ,"name" = "ASC"})
*/ */
#[Assert\Valid] #[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; protected Collection $parameters;
/**************************************** /****************************************
@ -106,4 +102,11 @@ class Footprint extends AbstractPartsContainingDBElement
return $this; 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();
}
} }

View file

@ -31,40 +31,43 @@ use Symfony\Component\Validator\Constraints as Assert;
/** /**
* Class Manufacturer. * 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 class Manufacturer extends AbstractCompany
{ {
/** #[ORM\ManyToOne(targetEntity: 'Manufacturer', inversedBy: 'children')]
* @ORM\ManyToOne(targetEntity="Manufacturer", inversedBy="children") #[ORM\JoinColumn(name: 'parent_id')]
* @ORM\JoinColumn(name="parent_id", referencedColumnName="id")
*/
protected ?\App\Entity\Base\AbstractStructuralDBElement $parent; protected ?\App\Entity\Base\AbstractStructuralDBElement $parent;
/** /**
* @ORM\OneToMany(targetEntity="Manufacturer", mappedBy="parent")
* @ORM\OrderBy({"name" = "ASC"})
* @var Collection * @var Collection
*/ */
#[ORM\OneToMany(targetEntity: 'Manufacturer', mappedBy: 'parent')]
#[ORM\OrderBy(['name' => 'ASC'])]
protected Collection $children; protected Collection $children;
/** /**
* @var Collection<int, ManufacturerAttachment> * @var Collection<int, ManufacturerAttachment>
* @ORM\OneToMany(targetEntity="App\Entity\Attachments\ManufacturerAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
* @ORM\OrderBy({"name" = "ASC"})
*/ */
#[Assert\Valid] #[Assert\Valid]
#[ORM\OneToMany(targetEntity: 'App\Entity\Attachments\ManufacturerAttachment', mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
#[ORM\OrderBy(['name' => 'ASC'])]
protected Collection $attachments; protected Collection $attachments;
/** @var Collection<int, ManufacturerParameter> /** @var Collection<int, ManufacturerParameter>
* @ORM\OneToMany(targetEntity="App\Entity\Parameters\ManufacturerParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
* @ORM\OrderBy({"group" = "ASC" ,"name" = "ASC"})
*/ */
#[Assert\Valid] #[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; 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();
}
} }

View file

@ -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 unit represents the unit in which the amount of parts in stock are measured.
* This could be something like N, grams, meters, etc... * 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')] #[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 class MeasurementUnit extends AbstractPartsContainingDBElement
{ {
/** /**
* @var string The unit symbol that should be used for the Unit. This could be something like "", g (for grams) * @var string The unit symbol that should be used for the Unit. This could be something like "", g (for grams)
* or m (for meters). * or m (for meters).
* @ORM\Column(type="string", name="unit", nullable=true)
*/ */
#[Assert\Length(max: 10)] #[Assert\Length(max: 10)]
#[Groups(['extended', 'full', 'import'])] #[Groups(['extended', 'full', 'import'])]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, name: 'unit', nullable: true)]
protected ?string $unit = null; protected ?string $unit = null;
/** /**
* @var bool Determines if the amount value associated with this unit should be treated as integer. * @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. * Set to false, to measure continuous sizes likes masses or lengths.
* @ORM\Column(type="boolean", name="is_integer")
*/ */
#[Groups(['extended', 'full', 'import'])] #[Groups(['extended', 'full', 'import'])]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN, name: 'is_integer')]
protected bool $is_integer = false; protected bool $is_integer = false;
/** /**
* @var bool Determines if the unit can be used with SI Prefixes (kilo, giga, milli, etc.). * @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 * 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')] #[Assert\Expression('this.isUseSIPrefix() == false or this.getUnit() != null', message: 'validator.measurement_unit.use_si_prefix_needs_unit')]
#[Groups(['full', 'import'])] #[Groups(['full', 'import'])]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN, name: 'use_si_prefix')]
protected bool $use_si_prefix = false; protected bool $use_si_prefix = false;
/** /**
* @ORM\OneToMany(targetEntity="MeasurementUnit", mappedBy="parent", cascade={"persist"})
* @ORM\OrderBy({"name" = "ASC"})
* @var Collection * @var Collection
*/ */
#[ORM\OneToMany(targetEntity: 'MeasurementUnit', mappedBy: 'parent', cascade: ['persist'])]
#[ORM\OrderBy(['name' => 'ASC'])]
protected Collection $children; protected Collection $children;
/** #[ORM\ManyToOne(targetEntity: 'MeasurementUnit', inversedBy: 'children')]
* @ORM\ManyToOne(targetEntity="MeasurementUnit", inversedBy="children") #[ORM\JoinColumn(name: 'parent_id')]
* @ORM\JoinColumn(name="parent_id", referencedColumnName="id")
*/
protected ?\App\Entity\Base\AbstractStructuralDBElement $parent; protected ?\App\Entity\Base\AbstractStructuralDBElement $parent;
/** /**
* @var Collection<int, MeasurementUnitAttachment> * @var Collection<int, MeasurementUnitAttachment>
* @ORM\OneToMany(targetEntity="App\Entity\Attachments\MeasurementUnitAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
* @ORM\OrderBy({"name" = "ASC"})
*/ */
#[Assert\Valid] #[Assert\Valid]
#[ORM\OneToMany(targetEntity: 'App\Entity\Attachments\MeasurementUnitAttachment', mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
#[ORM\OrderBy(['name' => 'ASC'])]
protected Collection $attachments; protected Collection $attachments;
/** @var Collection<int, MeasurementUnitParameter> /** @var Collection<int, MeasurementUnitParameter>
* @ORM\OneToMany(targetEntity="App\Entity\Parameters\MeasurementUnitParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
* @ORM\OrderBy({"group" = "ASC" ,"name" = "ASC"})
*/ */
#[Assert\Valid] #[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; protected Collection $parameters;
/** /**
@ -147,4 +143,11 @@ class MeasurementUnit extends AbstractPartsContainingDBElement
return $this; 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();
}
} }

View file

@ -34,32 +34,32 @@ trait AdvancedPropertyTrait
{ {
/** /**
* @var bool Determines if this part entry needs review (for example, because it is work in progress) * @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'])] #[Groups(['extended', 'full', 'import'])]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN)]
protected bool $needs_review = false; protected bool $needs_review = false;
/** /**
* @var string a comma separated list of tags, associated with the part * @var string a comma separated list of tags, associated with the part
* @ORM\Column(type="text")
*/ */
#[Groups(['extended', 'full', 'import'])] #[Groups(['extended', 'full', 'import'])]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT)]
protected string $tags = ''; protected string $tags = '';
/** /**
* @var float|null how much a single part unit weighs in grams * @var float|null how much a single part unit weighs in grams
* @ORM\Column(type="float", nullable=true)
*/ */
#[Assert\PositiveOrZero] #[Assert\PositiveOrZero]
#[Groups(['extended', 'full', 'import'])] #[Groups(['extended', 'full', 'import'])]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::FLOAT, nullable: true)]
protected ?float $mass = null; protected ?float $mass = null;
/** /**
* @var string|null The internal part number of the part * @var string|null The internal part number of the part
* @ORM\Column(type="string", length=100, nullable=true, unique=true)
*/ */
#[Assert\Length(max: 100)] #[Assert\Length(max: 100)]
#[Groups(['extended', 'full', 'import'])] #[Groups(['extended', 'full', 'import'])]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, length: 100, nullable: true, unique: true)]
protected ?string $ipn = null; protected ?string $ipn = null;
/** /**

View file

@ -33,49 +33,49 @@ trait BasicPropertyTrait
{ {
/** /**
* @var string A text describing what this part does * @var string A text describing what this part does
* @ORM\Column(type="text")
*/ */
#[Groups(['simple', 'extended', 'full', 'import'])] #[Groups(['simple', 'extended', 'full', 'import'])]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT)]
protected string $description = ''; protected string $description = '';
/** /**
* @var string A comment/note related to this part * @var string A comment/note related to this part
* @ORM\Column(type="text")
*/ */
#[Groups(['extended', 'full', 'import'])] #[Groups(['extended', 'full', 'import'])]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT)]
protected string $comment = ''; protected string $comment = '';
/** /**
* @var bool Kept for compatibility (it is not used now, and I don't think it was used in old versions) * @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; protected bool $visible = true;
/** /**
* @var bool true, if the part is marked as favorite * @var bool true, if the part is marked as favorite
* @ORM\Column(type="boolean")
*/ */
#[Groups(['extended', 'full', 'import'])] #[Groups(['extended', 'full', 'import'])]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN)]
protected bool $favorite = false; protected bool $favorite = false;
/** /**
* @var Category|null The category this part belongs too (e.g. Resistors). Use tags, for more complex grouping. * @var Category|null The category this part belongs too (e.g. Resistors). Use tags, for more complex grouping.
* Every part must have a category. * Every part must have a category.
* @ORM\ManyToOne(targetEntity="Category")
* @ORM\JoinColumn(name="id_category", referencedColumnName="id", nullable=false)
* @Selectable() * @Selectable()
*/ */
#[Assert\NotNull(message: 'validator.select_valid_category')] #[Assert\NotNull(message: 'validator.select_valid_category')]
#[Groups(['simple', 'extended', 'full', 'import'])] #[Groups(['simple', 'extended', 'full', 'import'])]
#[ORM\ManyToOne(targetEntity: 'Category')]
#[ORM\JoinColumn(name: 'id_category', nullable: false)]
protected ?Category $category = null; protected ?Category $category = null;
/** /**
* @var Footprint|null The footprint of this part (e.g. DIP8) * @var Footprint|null The footprint of this part (e.g. DIP8)
* @ORM\ManyToOne(targetEntity="Footprint")
* @ORM\JoinColumn(name="id_footprint", referencedColumnName="id")
* @Selectable() * @Selectable()
*/ */
#[Groups(['simple', 'extended', 'full', 'import'])] #[Groups(['simple', 'extended', 'full', 'import'])]
#[ORM\ManyToOne(targetEntity: 'Footprint')]
#[ORM\JoinColumn(name: 'id_footprint')]
protected ?Footprint $footprint = null; protected ?Footprint $footprint = null;
/** /**

View file

@ -36,28 +36,28 @@ trait InstockTrait
{ {
/** /**
* @var Collection|PartLot[] A list of part lots where this part is stored * @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] #[Assert\Valid]
#[Groups(['extended', 'full', 'import'])] #[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. * @var float The minimum amount of the part that has to be instock, otherwise more is ordered.
* Given in the partUnit. * Given in the partUnit.
* @ORM\Column(type="float")
*/ */
#[Assert\PositiveOrZero] #[Assert\PositiveOrZero]
#[Groups(['extended', 'full', 'import'])] #[Groups(['extended', 'full', 'import'])]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::FLOAT)]
protected float $minamount = 0; protected float $minamount = 0;
/** /**
* @var ?MeasurementUnit the unit in which the part's amount is measured * @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'])] #[Groups(['extended', 'full', 'import'])]
#[ORM\ManyToOne(targetEntity: 'MeasurementUnit')]
#[ORM\JoinColumn(name: 'id_part_unit')]
protected ?MeasurementUnit $partUnit = null; protected ?MeasurementUnit $partUnit = null;
/** /**

View file

@ -36,34 +36,34 @@ trait ManufacturerTrait
{ {
/** /**
* @var Manufacturer|null The manufacturer of this part * @var Manufacturer|null The manufacturer of this part
* @ORM\ManyToOne(targetEntity="Manufacturer")
* @ORM\JoinColumn(name="id_manufacturer", referencedColumnName="id")
* @Selectable() * @Selectable()
*/ */
#[Groups(['simple', 'extended', 'full', 'import'])] #[Groups(['simple', 'extended', 'full', 'import'])]
#[ORM\ManyToOne(targetEntity: 'Manufacturer')]
#[ORM\JoinColumn(name: 'id_manufacturer')]
protected ?Manufacturer $manufacturer = null; protected ?Manufacturer $manufacturer = null;
/** /**
* @var string the url to the part on the manufacturer's homepage * @var string the url to the part on the manufacturer's homepage
* @ORM\Column(type="string")
*/ */
#[Assert\Url] #[Assert\Url]
#[Groups(['full', 'import'])] #[Groups(['full', 'import'])]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING)]
protected string $manufacturer_product_url = ''; protected string $manufacturer_product_url = '';
/** /**
* @var string The product number used by the manufacturer. If this is set to "", the name field is used. * @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'])] #[Groups(['extended', 'full', 'import'])]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING)]
protected string $manufacturer_product_number = ''; protected string $manufacturer_product_number = '';
/** /**
* @var string|null The production status of this part. Can be one of the specified ones. * @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', ''])] #[Assert\Choice(['announced', 'active', 'nrfnd', 'eol', 'discontinued', ''])]
#[Groups(['extended', 'full', 'import'])] #[Groups(['extended', 'full', 'import'])]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, length: 255, nullable: true)]
protected ?string $manufacturing_status = ''; protected ?string $manufacturing_status = '';
/** /**

View file

@ -36,30 +36,30 @@ trait OrderTrait
{ {
/** /**
* @var Orderdetail[]|Collection the details about how and where you can order this part * @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] #[Assert\Valid]
#[Groups(['extended', 'full', 'import'])] #[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 * @var int
* @ORM\Column(type="integer")
*/ */
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER)]
protected int $order_quantity = 0; protected int $order_quantity = 0;
/** /**
* @var bool * @var bool
* @ORM\Column(type="boolean")
*/ */
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN)]
protected bool $manual_order = false; protected bool $manual_order = false;
/** /**
* @var Orderdetail|null * @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; protected ?Orderdetail $order_orderdetail = null;
/** /**

View file

@ -10,16 +10,16 @@ use Doctrine\ORM\Mapping as ORM;
trait ProjectTrait trait ProjectTrait
{ {
/** /**
* @var Collection<int, ProjectBOMEntry> $project_bom_entries * @var \Doctrine\Common\Collections\Collection<\App\Entity\ProjectSystem\ProjectBOMEntry> $project_bom_entries
* @ORM\OneToMany(targetEntity="App\Entity\ProjectSystem\ProjectBOMEntry", mappedBy="part", cascade={"remove"}, orphanRemoval=true)
*/ */
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. * @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; protected ?Project $built_project = null;
/** /**

View file

@ -34,82 +34,78 @@ use Symfony\Component\Validator\Constraints as Assert;
/** /**
* Class Store location. * 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 class Storelocation extends AbstractPartsContainingDBElement
{ {
/** /**
* @ORM\OneToMany(targetEntity="Storelocation", mappedBy="parent")
* @ORM\OrderBy({"name" = "ASC"})
* @var Collection * @var Collection
*/ */
#[ORM\OneToMany(targetEntity: 'Storelocation', mappedBy: 'parent')]
#[ORM\OrderBy(['name' => 'ASC'])]
protected Collection $children; protected Collection $children;
/** #[ORM\ManyToOne(targetEntity: 'Storelocation', inversedBy: 'children')]
* @ORM\ManyToOne(targetEntity="Storelocation", inversedBy="children") #[ORM\JoinColumn(name: 'parent_id')]
* @ORM\JoinColumn(name="parent_id", referencedColumnName="id")
*/
protected ?AbstractStructuralDBElement $parent; protected ?AbstractStructuralDBElement $parent;
/** /**
* @var MeasurementUnit|null The measurement unit, which parts can be stored in here * @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; protected ?MeasurementUnit $storage_type = null;
/** @var Collection<int, StorelocationParameter> /** @var Collection<int, StorelocationParameter>
* @ORM\OneToMany(targetEntity="App\Entity\Parameters\StorelocationParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
* @ORM\OrderBy({"group" = "ASC" ,"name" = "ASC"})
*/ */
#[Assert\Valid] #[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; protected Collection $parameters;
/** /**
* @var bool * @var bool
* @ORM\Column(type="boolean")
*/ */
#[Groups(['full', 'import'])] #[Groups(['full', 'import'])]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN)]
protected bool $is_full = false; protected bool $is_full = false;
/** /**
* @var bool * @var bool
* @ORM\Column(type="boolean")
*/ */
#[Groups(['full', 'import'])] #[Groups(['full', 'import'])]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN)]
protected bool $only_single_part = false; protected bool $only_single_part = false;
/** /**
* @var bool * @var bool
* @ORM\Column(type="boolean")
*/ */
#[Groups(['full', 'import'])] #[Groups(['full', 'import'])]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN)]
protected bool $limit_to_existing_parts = false; protected bool $limit_to_existing_parts = false;
/** /**
* @var User|null The owner of this storage location * @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')] #[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; 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. * @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; protected bool $part_owner_must_match = false;
/** /**
* @var Collection<int, StorelocationAttachment> * @var Collection<int, StorelocationAttachment>
* @ORM\OneToMany(targetEntity="App\Entity\Attachments\StorelocationAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
*/ */
#[Assert\Valid] #[Assert\Valid]
#[ORM\OneToMany(targetEntity: 'App\Entity\Attachments\StorelocationAttachment', mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
protected Collection $attachments; protected Collection $attachments;
/******************************************************************************** /********************************************************************************
@ -248,4 +244,11 @@ class Storelocation extends AbstractPartsContainingDBElement
return $this; 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();
}
} }

View file

@ -37,63 +37,60 @@ use Symfony\Component\Validator\Constraints as Assert;
/** /**
* Class Supplier. * 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 class Supplier extends AbstractCompany
{ {
/** /**
* @ORM\OneToMany(targetEntity="Supplier", mappedBy="parent")
* @ORM\OrderBy({"name" = "ASC"})
* @var Collection * @var Collection
*/ */
#[ORM\OneToMany(targetEntity: 'Supplier', mappedBy: 'parent')]
#[ORM\OrderBy(['name' => 'ASC'])]
protected Collection $children; protected Collection $children;
/** #[ORM\ManyToOne(targetEntity: 'Supplier', inversedBy: 'children')]
* @ORM\ManyToOne(targetEntity="Supplier", inversedBy="children") #[ORM\JoinColumn(name: 'parent_id')]
* @ORM\JoinColumn(name="parent_id", referencedColumnName="id")
*/
protected ?AbstractStructuralDBElement $parent; protected ?AbstractStructuralDBElement $parent;
/** /**
* @ORM\OneToMany(targetEntity="App\Entity\PriceInformations\Orderdetail", mappedBy="supplier") * @var \Doctrine\Common\Collections\Collection<int, \App\Entity\PriceInformations\Orderdetail>|\App\Entity\PriceInformations\Orderdetail[]
*/ */
#[ORM\OneToMany(targetEntity: 'App\Entity\PriceInformations\Orderdetail', mappedBy: 'supplier')]
protected Collection $orderdetails; protected Collection $orderdetails;
/** /**
* @var Currency|null The currency that should be used by default for order informations with this supplier. * @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. * 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() * @Selectable()
*/ */
#[ORM\ManyToOne(targetEntity: 'App\Entity\PriceInformations\Currency')]
#[ORM\JoinColumn(name: 'default_currency_id')]
protected ?Currency $default_currency = null; protected ?Currency $default_currency = null;
/** /**
* @var BigDecimal|null the shipping costs that have to be paid, when ordering via this supplier * @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() * @BigDecimalPositiveOrZero()
*/ */
#[Groups(['extended', 'full', 'import'])] #[Groups(['extended', 'full', 'import'])]
#[ORM\Column(name: 'shipping_costs', nullable: true, type: 'big_decimal', precision: 11, scale: 5)]
protected ?BigDecimal $shipping_costs = null; protected ?BigDecimal $shipping_costs = null;
/** /**
* @var Collection<int, SupplierAttachment> * @var Collection<int, SupplierAttachment>
* @ORM\OneToMany(targetEntity="App\Entity\Attachments\SupplierAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
* @ORM\OrderBy({"name" = "ASC"})
*/ */
#[Assert\Valid] #[Assert\Valid]
#[ORM\OneToMany(targetEntity: 'App\Entity\Attachments\SupplierAttachment', mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
#[ORM\OrderBy(['name' => 'ASC'])]
protected Collection $attachments; protected Collection $attachments;
/** @var Collection<int, SupplierParameter> /** @var Collection<int, SupplierParameter>
* @ORM\OneToMany(targetEntity="App\Entity\Parameters\SupplierParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
* @ORM\OrderBy({"group" = "ASC" ,"name" = "ASC"})
*/ */
#[Assert\Valid] #[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; protected Collection $parameters;
/** /**
@ -146,4 +143,12 @@ class Supplier extends AbstractCompany
return $this; 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();
}
} }

View file

@ -37,14 +37,12 @@ use Symfony\Component\Validator\Constraints as Assert;
/** /**
* This entity describes a currency that can be used for price information. * 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')] #[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 class Currency extends AbstractStructuralDBElement
{ {
public const PRICE_SCALE = 5; 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 * @var BigDecimal|null The exchange rate between this currency and the base currency
* (how many base units the current currency is worth) * (how many base units the current currency is worth)
* @ORM\Column(type="big_decimal", precision=11, scale=5, nullable=true)
* @BigDecimalPositive() * @BigDecimalPositive()
*/ */
#[ORM\Column(type: 'big_decimal', precision: 11, scale: 5, nullable: true)]
protected ?BigDecimal $exchange_rate = null; protected ?BigDecimal $exchange_rate = null;
/** /**
* @var string the 3-letter ISO code of the currency * @var string the 3-letter ISO code of the currency
* @ORM\Column(type="string")
*/ */
#[Assert\Currency] #[Assert\Currency]
#[Groups(['extended', 'full', 'import'])] #[Groups(['extended', 'full', 'import'])]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING)]
protected string $iso_code = ""; protected string $iso_code = "";
/** #[ORM\OneToMany(targetEntity: 'Currency', mappedBy: 'parent', cascade: ['persist'])]
* @ORM\OneToMany(targetEntity="Currency", mappedBy="parent", cascade={"persist"}) #[ORM\OrderBy(['name' => 'ASC'])]
* @ORM\OrderBy({"name" = "ASC"})
*/
protected Collection $children; protected Collection $children;
/** #[ORM\ManyToOne(targetEntity: 'Currency', inversedBy: 'children')]
* @ORM\ManyToOne(targetEntity="Currency", inversedBy="children") #[ORM\JoinColumn(name: 'parent_id')]
* @ORM\JoinColumn(name="parent_id", referencedColumnName="id")
*/
protected ?AbstractStructuralDBElement $parent; protected ?AbstractStructuralDBElement $parent;
/** /**
* @var Collection<int, CurrencyAttachment> * @var Collection<int, CurrencyAttachment>
* @ORM\OneToMany(targetEntity="App\Entity\Attachments\CurrencyAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
* @ORM\OrderBy({"name" = "ASC"})
*/ */
#[Assert\Valid] #[Assert\Valid]
#[ORM\OneToMany(targetEntity: 'App\Entity\Attachments\CurrencyAttachment', mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
#[ORM\OrderBy(['name' => 'ASC'])]
protected Collection $attachments; protected Collection $attachments;
/** @var Collection<int, CurrencyParameter> /** @var Collection<int, CurrencyParameter>
* @ORM\OneToMany(targetEntity="App\Entity\Parameters\CurrencyParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
* @ORM\OrderBy({"group" = "ASC" ,"name" = "ASC"})
*/ */
#[Assert\Valid] #[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; protected Collection $parameters;
/** @var Collection<int, Pricedetail> /** @var Collection<int, Pricedetail>
* @ORM\OneToMany(targetEntity="App\Entity\PriceInformations\Pricedetail", mappedBy="currency")
*/ */
#[ORM\OneToMany(targetEntity: 'App\Entity\PriceInformations\Pricedetail', mappedBy: 'currency')]
protected Collection $pricedetails; protected Collection $pricedetails;
public function __construct() 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(); $this->pricedetails = new ArrayCollection();
parent::__construct(); parent::__construct();
} }

View file

@ -39,63 +39,59 @@ use Symfony\Component\Validator\Constraints as Assert;
/** /**
* Class Orderdetail. * Class Orderdetail.
*
* @ORM\Table("`orderdetails`", indexes={
* @ORM\Index(name="orderdetails_supplier_part_nr", columns={"supplierpartnr"}),
* })
* @ORM\Entity()
* @ORM\HasLifecycleCallbacks()
*/ */
#[UniqueEntity(['supplierpartnr', 'supplier', 'part'])] #[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 class Orderdetail extends AbstractDBElement implements TimeStampableInterface, NamedElementInterface
{ {
use TimestampTrait; use TimestampTrait;
/**
* @ORM\OneToMany(targetEntity="Pricedetail", mappedBy="orderdetail", cascade={"persist", "remove"}, orphanRemoval=true)
* @ORM\OrderBy({"min_discount_quantity" = "ASC"})
*/
#[Assert\Valid] #[Assert\Valid]
#[Groups(['extended', 'full', 'import'])] #[Groups(['extended', 'full', 'import'])]
#[ORM\OneToMany(targetEntity: 'Pricedetail', mappedBy: 'orderdetail', cascade: ['persist', 'remove'], orphanRemoval: true)]
#[ORM\OrderBy(['min_discount_quantity' => 'ASC'])]
protected Collection $pricedetails; protected Collection $pricedetails;
/** /**
* @var string * @var string
* @ORM\Column(type="string")
*/ */
#[Groups(['extended', 'full', 'import'])] #[Groups(['extended', 'full', 'import'])]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING)]
protected string $supplierpartnr = ''; protected string $supplierpartnr = '';
/** /**
* @var bool * @var bool
* @ORM\Column(type="boolean")
*/ */
#[Groups(['extended', 'full', 'import'])] #[Groups(['extended', 'full', 'import'])]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN)]
protected bool $obsolete = false; protected bool $obsolete = false;
/** /**
* @var string * @var string
* @ORM\Column(type="string")
*/ */
#[Assert\Url] #[Assert\Url]
#[Groups(['full', 'import'])] #[Groups(['full', 'import'])]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING)]
protected string $supplier_product_url = ''; protected string $supplier_product_url = '';
/** /**
* @var Part|null * @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] #[Assert\NotNull]
#[ORM\ManyToOne(targetEntity: 'App\Entity\Parts\Part', inversedBy: 'orderdetails')]
#[ORM\JoinColumn(name: 'part_id', nullable: false, onDelete: 'CASCADE')]
protected ?Part $part = null; protected ?Part $part = null;
/** /**
* @var Supplier|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')] #[Assert\NotNull(message: 'validator.orderdetail.supplier_must_not_be_null')]
#[Groups(['extended', 'full', 'import'])] #[Groups(['extended', 'full', 'import'])]
#[ORM\ManyToOne(targetEntity: 'App\Entity\Parts\Supplier', inversedBy: 'orderdetails')]
#[ORM\JoinColumn(name: 'id_supplier')]
protected ?Supplier $supplier = null; protected ?Supplier $supplier = null;
public function __construct() 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. * 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 public function updateTimestamps(): void
{ {
$this->lastModified = new DateTime('now'); $this->lastModified = new DateTime('now');

View file

@ -37,15 +37,13 @@ use Symfony\Component\Validator\Constraints as Assert;
/** /**
* Class Pricedetail. * 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'])] #[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 class Pricedetail extends AbstractDBElement implements TimeStampableInterface
{ {
use TimestampTrait; 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) * @var BigDecimal The price related to the detail. (Given in the selected currency)
* @ORM\Column(type="big_decimal", precision=11, scale=5)
* @BigDecimalPositive() * @BigDecimalPositive()
*/ */
#[Groups(['extended', 'full'])] #[Groups(['extended', 'full'])]
#[ORM\Column(type: 'big_decimal', precision: 11, scale: 5)]
protected BigDecimal $price; protected BigDecimal $price;
/** /**
* @var ?Currency The currency used for the current price information. * @var ?Currency The currency used for the current price information.
* If this is null, the global base unit is assumed. * 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() * @Selectable()
*/ */
#[Groups(['extended', 'full', 'import'])] #[Groups(['extended', 'full', 'import'])]
#[ORM\ManyToOne(targetEntity: 'Currency', inversedBy: 'pricedetails')]
#[ORM\JoinColumn(name: 'id_currency')]
protected ?Currency $currency = null; protected ?Currency $currency = null;
/** /**
* @var float * @var float
* @ORM\Column(type="float")
*/ */
#[Assert\Positive] #[Assert\Positive]
#[Groups(['extended', 'full', 'import'])] #[Groups(['extended', 'full', 'import'])]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::FLOAT)]
protected float $price_related_quantity = 1.0; protected float $price_related_quantity = 1.0;
/** /**
* @var float * @var float
* @ORM\Column(type="float")
*/ */
#[Assert\Positive] #[Assert\Positive]
#[Groups(['extended', 'full', 'import'])] #[Groups(['extended', 'full', 'import'])]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::FLOAT)]
protected float $min_discount_quantity = 1.0; protected float $min_discount_quantity = 1.0;
/** /**
* @var bool * @var bool
* @ORM\Column(type="boolean")
*/ */
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN)]
protected bool $manual_input = true; protected bool $manual_input = true;
/** /**
* @var Orderdetail|null * @var Orderdetail|null
* @ORM\ManyToOne(targetEntity="Orderdetail", inversedBy="pricedetails")
* @ORM\JoinColumn(name="orderdetails_id", referencedColumnName="id", nullable=false, onDelete="CASCADE")
*/ */
#[Assert\NotNull] #[Assert\NotNull]
#[ORM\ManyToOne(targetEntity: 'Orderdetail', inversedBy: 'pricedetails')]
#[ORM\JoinColumn(name: 'orderdetails_id', nullable: false, onDelete: 'CASCADE')]
protected ?Orderdetail $orderdetail = null; protected ?Orderdetail $orderdetail = null;
public function __construct() 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. * 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 public function updateTimestamps(): void
{ {
$this->lastModified = new DateTime('now'); $this->lastModified = new DateTime('now');

View file

@ -36,74 +36,63 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface;
/** /**
* Class AttachmentType. * 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 class Project extends AbstractStructuralDBElement
{ {
/** /**
* @ORM\OneToMany(targetEntity="Project", mappedBy="parent")
* @ORM\OrderBy({"name" = "ASC"})
* @var Collection * @var Collection
*/ */
#[ORM\OneToMany(targetEntity: 'Project', mappedBy: 'parent')]
#[ORM\OrderBy(['name' => 'ASC'])]
protected Collection $children; protected Collection $children;
/** #[ORM\ManyToOne(targetEntity: 'Project', inversedBy: 'children')]
* @ORM\ManyToOne(targetEntity="Project", inversedBy="children") #[ORM\JoinColumn(name: 'parent_id')]
* @ORM\JoinColumn(name="parent_id", referencedColumnName="id")
*/
protected ?AbstractStructuralDBElement $parent; protected ?AbstractStructuralDBElement $parent;
/**
* @ORM\OneToMany(targetEntity="ProjectBOMEntry", mappedBy="project", cascade={"persist", "remove"}, orphanRemoval=true)
*/
#[Assert\Valid] #[Assert\Valid]
#[Groups(['extended', 'full'])] #[Groups(['extended', 'full'])]
#[ORM\OneToMany(targetEntity: 'ProjectBOMEntry', mappedBy: 'project', cascade: ['persist', 'remove'], orphanRemoval: true)]
protected Collection $bom_entries; protected Collection $bom_entries;
/** #[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER)]
* @ORM\Column(type="integer")
*/
protected int $order_quantity = 0; protected int $order_quantity = 0;
/** /**
* @var string|null The current status of the project * @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'])] #[Assert\Choice(['draft', 'planning', 'in_production', 'finished', 'archived'])]
#[Groups(['extended', 'full'])] #[Groups(['extended', 'full'])]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, length: 64, nullable: true)]
protected ?string $status = null; protected ?string $status = null;
/** /**
* @var Part|null The (optional) part that represents the builds of this project in the stock * @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; protected ?Part $build_part = null;
/** #[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN)]
* @ORM\Column(type="boolean")
*/
protected bool $order_only_missing_parts = false; protected bool $order_only_missing_parts = false;
/**
* @ORM\Column(type="text", nullable=false)
*/
#[Groups(['simple', 'extended', 'full'])] #[Groups(['simple', 'extended', 'full'])]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT)]
protected string $description = ''; protected string $description = '';
/** /**
* @var Collection<int, ProjectAttachment> * @var Collection<int, ProjectAttachment>
* @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; protected Collection $attachments;
/** @var Collection<int, ProjectParameter> /** @var Collection<int, ProjectParameter>
* @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; protected Collection $parameters;
/******************************************************************************** /********************************************************************************
@ -114,6 +103,8 @@ class Project extends AbstractStructuralDBElement
public function __construct() public function __construct()
{ {
$this->attachments = new \Doctrine\Common\Collections\ArrayCollection();
$this->parameters = new \Doctrine\Common\Collections\ArrayCollection();
parent::__construct(); parent::__construct();
$this->bom_entries = new ArrayCollection(); $this->bom_entries = new ArrayCollection();
$this->children = new ArrayCollection(); $this->children = new ArrayCollection();

View file

@ -36,70 +36,69 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface;
/** /**
* The ProjectBOMEntry class represents an entry in a project's BOM. * 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: ['part', 'project'], message: 'project.bom_entry.part_already_in_bom')]
#[UniqueEntity(fields: ['name', 'project'], message: 'project.bom_entry.name_already_in_bom', ignoreNull: true)] #[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 class ProjectBOMEntry extends AbstractDBElement
{ {
use TimestampTrait; use TimestampTrait;
/** /**
* @var float * @var float
* @ORM\Column(type="float", name="quantity")
*/ */
#[Assert\Positive] #[Assert\Positive]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::FLOAT, name: 'quantity')]
protected float $quantity; protected float $quantity;
/** /**
* @var string A comma separated list of the names, where this parts should be placed * @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 = ''; protected string $mountnames = '';
/** /**
* @var string|null An optional name describing this BOM entry (useful for non-part entries) * @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')] #[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; protected ?string $name = null;
/** /**
* @var string An optional comment for this BOM entry * @var string An optional comment for this BOM entry
* @ORM\Column(type="text")
*/ */
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT)]
protected string $comment; protected string $comment;
/** /**
* @var Project|null * @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; protected ?Project $project = null;
/** /**
* @var Part|null The part associated with this * @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; protected ?Part $part = null;
/** /**
* @var BigDecimal|null The price of this non-part BOM entry * @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()])] #[Assert\AtLeastOneOf([new BigDecimalPositive(), new Assert\IsNull()])]
#[ORM\Column(type: 'big_decimal', precision: 11, scale: 5, nullable: true)]
protected ?BigDecimal $price; protected ?BigDecimal $price;
/** /**
* @var ?Currency The currency for the price of this non-part BOM entry * @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() * @Selectable()
*/ */
#[ORM\ManyToOne(targetEntity: 'App\Entity\PriceInformations\Currency')]
#[ORM\JoinColumn]
protected ?Currency $price_currency = null; protected ?Currency $price_currency = null;
public function __construct() public function __construct()

View file

@ -35,65 +35,63 @@ use Symfony\Component\Validator\Constraints as Assert;
/** /**
* This entity represents a user group. * 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 class Group extends AbstractStructuralDBElement implements HasPermissionsInterface
{ {
/** /**
* @ORM\OneToMany(targetEntity="Group", mappedBy="parent")
* @ORM\OrderBy({"name" = "ASC"})
* @var Collection<int, self> * @var Collection<int, self>
*/ */
#[ORM\OneToMany(targetEntity: 'Group', mappedBy: 'parent')]
#[ORM\OrderBy(['name' => 'ASC'])]
protected Collection $children; protected Collection $children;
/** #[ORM\ManyToOne(targetEntity: 'Group', inversedBy: 'children')]
* @ORM\ManyToOne(targetEntity="Group", inversedBy="children") #[ORM\JoinColumn(name: 'parent_id')]
* @ORM\JoinColumn(name="parent_id", referencedColumnName="id")
*/
protected ?AbstractStructuralDBElement $parent; protected ?AbstractStructuralDBElement $parent;
/** /**
* @ORM\OneToMany(targetEntity="User", mappedBy="group")
* @var Collection<int, User> * @var Collection<int, User>
*/ */
#[ORM\OneToMany(targetEntity: 'User', mappedBy: 'group')]
protected Collection $users; protected Collection $users;
/** /**
* @var bool If true all users associated with this group must have enabled some kind of two-factor authentication * @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'])] #[Groups(['extended', 'full', 'import'])]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN, name: 'enforce_2fa')]
protected bool $enforce2FA = false; protected bool $enforce2FA = false;
/** /**
* @var Collection<int, GroupAttachment> * @var Collection<int, GroupAttachment>
* @ORM\OneToMany(targetEntity="App\Entity\Attachments\GroupAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
* @ORM\OrderBy({"name" = "ASC"})
*/ */
#[Assert\Valid] #[Assert\Valid]
#[ORM\OneToMany(targetEntity: 'App\Entity\Attachments\GroupAttachment', mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
#[ORM\OrderBy(['name' => 'ASC'])]
protected Collection $attachments; protected Collection $attachments;
/** /**
* @var PermissionData|null * @var PermissionData|null
* @ValidPermission() * @ValidPermission()
* @ORM\Embedded(class="PermissionData", columnPrefix="permissions_")
*/ */
#[Groups(['full'])] #[Groups(['full'])]
#[ORM\Embedded(class: 'PermissionData', columnPrefix: 'permissions_')]
protected ?PermissionData $permissions = null; protected ?PermissionData $permissions = null;
/** @var Collection<int, GroupParameter> /** @var Collection<int, GroupParameter>
* @ORM\OneToMany(targetEntity="App\Entity\Parameters\GroupParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
* @ORM\OrderBy({"group" = "ASC" ,"name" = "ASC"})
*/ */
#[Assert\Valid] #[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; protected Collection $parameters;
public function __construct() public function __construct()
{ {
$this->attachments = new \Doctrine\Common\Collections\ArrayCollection();
$this->parameters = new \Doctrine\Common\Collections\ArrayCollection();
parent::__construct(); parent::__construct();
$this->permissions = new PermissionData(); $this->permissions = new PermissionData();
$this->users = new ArrayCollection(); $this->users = new ArrayCollection();

View file

@ -25,9 +25,8 @@ use Doctrine\ORM\Mapping as ORM;
/** /**
* This class is used to store the permissions of a user. * 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) * 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 final class PermissionData implements \JsonSerializable
{ {
/** /**
@ -48,8 +47,8 @@ final class PermissionData implements \JsonSerializable
* permission => [ * permission => [
* operation => value, * operation => value,
* ] * ]
* @ORM\Column(type="json", name="data")
*/ */
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON, name: 'data')]
protected ?array $data = [ protected ?array $data = [
//$ prefixed entries are used for metadata //$ prefixed entries are used for metadata
'$ver' => self::CURRENT_SCHEMA_VERSION, //The schema version of the permission data '$ver' => self::CURRENT_SCHEMA_VERSION, //The schema version of the permission data

View file

@ -26,15 +26,10 @@ use App\Entity\Base\TimestampTrait;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Jbtronics\TFAWebauthn\Model\LegacyU2FKeyInterface; use Jbtronics\TFAWebauthn\Model\LegacyU2FKeyInterface;
/** #[ORM\Entity]
* @ORM\Entity #[ORM\HasLifecycleCallbacks]
* @ORM\Table(name="u2f_keys", #[ORM\Table(name: 'u2f_keys')]
* uniqueConstraints={ #[ORM\UniqueConstraint(name: 'user_unique', columns: ['user_id', 'key_handle'])]
* @ORM\UniqueConstraint(name="user_unique",columns={"user_id",
* "key_handle"})
* })
* @ORM\HasLifecycleCallbacks()
*/
class U2FKey implements LegacyU2FKeyInterface class U2FKey implements LegacyU2FKeyInterface
{ {
use TimestampTrait; 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. * 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). * 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 * @var string
**/ **/
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, length: 128)]
public string $keyHandle; public string $keyHandle;
/** /**
* @ORM\Column(type="string")
*
* @var string * @var string
**/ **/
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING)]
public string $publicKey; public string $publicKey;
/** /**
* @ORM\Column(type="text")
*
* @var string * @var string
**/ **/
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT)]
public string $certificate; public string $certificate;
/** /**
* @ORM\Column(type="string")
*
* @var int * @var int
**/ **/
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING)]
public int $counter; public int $counter;
/** #[ORM\Id]
* @ORM\Id #[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER)]
* @ORM\Column(type="integer") #[ORM\GeneratedValue]
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected int $id; protected int $id;
/** /**
* @ORM\Column(type="string")
*
* @var string * @var string
**/ **/
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING)]
protected string $name; 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; protected ?User $user = null;
public function getKeyHandle(): string public function getKeyHandle(): string

View file

@ -24,30 +24,22 @@ use App\Entity\Base\TimestampTrait;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Webauthn\PublicKeyCredentialSource as BasePublicKeyCredentialSource; use Webauthn\PublicKeyCredentialSource as BasePublicKeyCredentialSource;
/** #[ORM\Entity]
* @ORM\Table(name="webauthn_keys") #[ORM\HasLifecycleCallbacks]
* @ORM\Entity() #[ORM\Table(name: 'webauthn_keys')]
* @ORM\HasLifecycleCallbacks()
*/
class WebauthnKey extends BasePublicKeyCredentialSource class WebauthnKey extends BasePublicKeyCredentialSource
{ {
use TimestampTrait; use TimestampTrait;
/** #[ORM\Id]
* @ORM\Id #[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER)]
* @ORM\Column(type="integer") #[ORM\GeneratedValue]
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected int $id; protected int $id;
/** #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING)]
* @ORM\Column(type="string")
*/
protected string $name; 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; protected ?User $user = null;
/** /**

View file

@ -54,9 +54,8 @@ class AttachmentDeleteListener
/** /**
* Removes the file associated with the attachment, if the file associated with the attachment changes. * 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 public function preUpdateHandler(Attachment $attachment, PreUpdateEventArgs $event): void
{ {
if ($event->hasChangedField('path')) { 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). * 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 public function preRemoveHandler(Attachment $attachment, PreRemoveEventArgs $event): void
{ {
//Ensure that the attachment that will be deleted, is not used as preview picture anymore... //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. * Removes the file associated with the attachment, after the attachment was deleted.
*
* @PostRemove
*/ */
#[PostRemove]
public function postRemoveHandler(Attachment $attachment, PostRemoveEventArgs $event): void public function postRemoveHandler(Attachment $attachment, PostRemoveEventArgs $event): void
{ {
//Dont delete file if the attachment uses a builtin ressource: //Dont delete file if the attachment uses a builtin ressource:

View file

@ -44,11 +44,9 @@ class TreeCacheInvalidationListener
$this->keyGenerator = $keyGenerator; $this->keyGenerator = $keyGenerator;
} }
/** #[ORM\PostUpdate]
* @ORM\PostUpdate() #[ORM\PostPersist]
* @ORM\PostPersist() #[ORM\PostRemove]
* @ORM\PostRemove()
*/
public function invalidate(AbstractDBElement $element, LifecycleEventArgs $event): void public function invalidate(AbstractDBElement $element, LifecycleEventArgs $event): void
{ {
//If an element was changed, then invalidate all cached trees with this element class //If an element was changed, then invalidate all cached trees with this element class