mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-03 06:54:34 +02:00
Applied rector with PHP8.1 migration rules
This commit is contained in:
parent
dc6a67c2f0
commit
7ee01d9a05
303 changed files with 1228 additions and 3465 deletions
|
@ -34,11 +34,11 @@ use LogicException;
|
|||
/**
|
||||
* Class Attachment.
|
||||
*/
|
||||
#[ORM\Entity(repositoryClass: 'App\Repository\AttachmentRepository')]
|
||||
#[ORM\Entity(repositoryClass: \App\Repository\AttachmentRepository::class)]
|
||||
#[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\EntityListeners([\App\EntityListeners\AttachmentDeleteListener::class])]
|
||||
#[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'])]
|
||||
|
@ -51,23 +51,23 @@ abstract class Attachment extends AbstractNamedDBElement
|
|||
* Based on: https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Image_types
|
||||
* It will be used to determine if an attachment is a picture and therefore will be shown to user as preview.
|
||||
*/
|
||||
public const PICTURE_EXTS = ['apng', 'bmp', 'gif', 'ico', 'cur', 'jpg', 'jpeg', 'jfif', 'pjpeg', 'pjp', 'png',
|
||||
final public const PICTURE_EXTS = ['apng', 'bmp', 'gif', 'ico', 'cur', 'jpg', 'jpeg', 'jfif', 'pjpeg', 'pjp', 'png',
|
||||
'svg', 'webp', ];
|
||||
|
||||
/**
|
||||
* A list of extensions that will be treated as a 3D Model that can be shown to user directly in Part-DB.
|
||||
*/
|
||||
public const MODEL_EXTS = ['x3d'];
|
||||
final public const MODEL_EXTS = ['x3d'];
|
||||
|
||||
/**
|
||||
* When the path begins with one of the placeholders.
|
||||
*/
|
||||
public const INTERNAL_PLACEHOLDER = ['%BASE%', '%MEDIA%', '%SECURE%'];
|
||||
final public const INTERNAL_PLACEHOLDER = ['%BASE%', '%MEDIA%', '%SECURE%'];
|
||||
|
||||
/**
|
||||
* @var array placeholders for attachments which using built in files
|
||||
*/
|
||||
public const BUILTIN_PLACEHOLDER = ['%FOOTPRINTS%', '%FOOTPRINTS3D%'];
|
||||
final public const BUILTIN_PLACEHOLDER = ['%FOOTPRINTS%', '%FOOTPRINTS3D%'];
|
||||
|
||||
/**
|
||||
* @var string The class of the element that can be passed to this attachment. Must be overridden in subclasses.
|
||||
|
|
|
@ -33,7 +33,7 @@ use Symfony\Component\Validator\Constraints as Assert;
|
|||
/**
|
||||
* Class AttachmentType.
|
||||
*/
|
||||
#[ORM\Entity(repositoryClass: 'App\Repository\StructuralDBElementRepository')]
|
||||
#[ORM\Entity(repositoryClass: \App\Repository\StructuralDBElementRepository::class)]
|
||||
#[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'])]
|
||||
|
@ -45,7 +45,7 @@ class AttachmentType extends AbstractStructuralDBElement
|
|||
|
||||
#[ORM\ManyToOne(targetEntity: 'AttachmentType', inversedBy: 'children')]
|
||||
#[ORM\JoinColumn(name: 'parent_id')]
|
||||
protected ?AbstractStructuralDBElement $parent;
|
||||
protected ?AbstractStructuralDBElement $parent = null;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
|
@ -57,14 +57,14 @@ class AttachmentType extends AbstractStructuralDBElement
|
|||
* @var Collection<int, AttachmentTypeAttachment>
|
||||
*/
|
||||
#[Assert\Valid]
|
||||
#[ORM\OneToMany(targetEntity: 'App\Entity\Attachments\AttachmentTypeAttachment', mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
|
||||
#[ORM\OneToMany(targetEntity: \App\Entity\Attachments\AttachmentTypeAttachment::class, mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
|
||||
#[ORM\OrderBy(['name' => 'ASC'])]
|
||||
protected Collection $attachments;
|
||||
|
||||
/** @var Collection<int, AttachmentTypeParameter>
|
||||
*/
|
||||
#[Assert\Valid]
|
||||
#[ORM\OneToMany(targetEntity: 'App\Entity\Parameters\AttachmentTypeParameter', mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
|
||||
#[ORM\OneToMany(targetEntity: \App\Entity\Parameters\AttachmentTypeParameter::class, mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
|
||||
#[ORM\OrderBy(['group' => 'ASC', 'name' => 'ASC'])]
|
||||
protected Collection $parameters;
|
||||
|
||||
|
|
|
@ -32,11 +32,11 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
|||
#[ORM\Entity]
|
||||
class AttachmentTypeAttachment extends Attachment
|
||||
{
|
||||
public const ALLOWED_ELEMENT_CLASS = AttachmentType::class;
|
||||
final public const ALLOWED_ELEMENT_CLASS = AttachmentType::class;
|
||||
/**
|
||||
* @var AttachmentContainingDBElement|null the element this attachment is associated with
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: 'App\Entity\Attachments\AttachmentType', inversedBy: 'attachments')]
|
||||
#[ORM\ManyToOne(targetEntity: \App\Entity\Attachments\AttachmentType::class, inversedBy: 'attachments')]
|
||||
#[ORM\JoinColumn(name: 'element_id', nullable: false, onDelete: 'CASCADE')]
|
||||
protected ?AttachmentContainingDBElement $element = null;
|
||||
}
|
||||
|
|
|
@ -33,11 +33,11 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
|||
#[ORM\Entity]
|
||||
class CategoryAttachment extends Attachment
|
||||
{
|
||||
public const ALLOWED_ELEMENT_CLASS = Category::class;
|
||||
final public const ALLOWED_ELEMENT_CLASS = Category::class;
|
||||
/**
|
||||
* @var AttachmentContainingDBElement|null the element this attachment is associated with
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: 'App\Entity\Parts\Category', inversedBy: 'attachments')]
|
||||
#[ORM\ManyToOne(targetEntity: \App\Entity\Parts\Category::class, inversedBy: 'attachments')]
|
||||
#[ORM\JoinColumn(name: 'element_id', nullable: false, onDelete: 'CASCADE')]
|
||||
protected ?AttachmentContainingDBElement $element = null;
|
||||
}
|
||||
|
|
|
@ -33,11 +33,11 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
|||
#[ORM\Entity]
|
||||
class CurrencyAttachment extends Attachment
|
||||
{
|
||||
public const ALLOWED_ELEMENT_CLASS = Currency::class;
|
||||
final public const ALLOWED_ELEMENT_CLASS = Currency::class;
|
||||
/**
|
||||
* @var Currency|null the element this attachment is associated with
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: 'App\Entity\PriceInformations\Currency', inversedBy: 'attachments')]
|
||||
#[ORM\ManyToOne(targetEntity: \App\Entity\PriceInformations\Currency::class, inversedBy: 'attachments')]
|
||||
#[ORM\JoinColumn(name: 'element_id', nullable: false, onDelete: 'CASCADE')]
|
||||
protected ?AttachmentContainingDBElement $element = null;
|
||||
}
|
||||
|
|
|
@ -33,11 +33,11 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
|||
#[ORM\Entity]
|
||||
class FootprintAttachment extends Attachment
|
||||
{
|
||||
public const ALLOWED_ELEMENT_CLASS = Footprint::class;
|
||||
final public const ALLOWED_ELEMENT_CLASS = Footprint::class;
|
||||
/**
|
||||
* @var Footprint|null the element this attachment is associated with
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: 'App\Entity\Parts\Footprint', inversedBy: 'attachments')]
|
||||
#[ORM\ManyToOne(targetEntity: \App\Entity\Parts\Footprint::class, inversedBy: 'attachments')]
|
||||
#[ORM\JoinColumn(name: 'element_id', nullable: false, onDelete: 'CASCADE')]
|
||||
protected ?AttachmentContainingDBElement $element = null;
|
||||
}
|
||||
|
|
|
@ -33,12 +33,12 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
|||
#[ORM\Entity]
|
||||
class GroupAttachment extends Attachment
|
||||
{
|
||||
public const ALLOWED_ELEMENT_CLASS = Group::class;
|
||||
final public const ALLOWED_ELEMENT_CLASS = Group::class;
|
||||
|
||||
/**
|
||||
* @var Group|null the element this attachment is associated with
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: 'App\Entity\UserSystem\Group', inversedBy: 'attachments')]
|
||||
#[ORM\ManyToOne(targetEntity: \App\Entity\UserSystem\Group::class, inversedBy: 'attachments')]
|
||||
#[ORM\JoinColumn(name: 'element_id', nullable: false, onDelete: 'CASCADE')]
|
||||
protected ?AttachmentContainingDBElement $element = null;
|
||||
}
|
||||
|
|
|
@ -52,12 +52,12 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
|||
#[ORM\Entity]
|
||||
class LabelAttachment extends Attachment
|
||||
{
|
||||
public const ALLOWED_ELEMENT_CLASS = LabelProfile::class;
|
||||
final public const ALLOWED_ELEMENT_CLASS = LabelProfile::class;
|
||||
|
||||
/**
|
||||
* @var LabelProfile the element this attachment is associated with
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: 'App\Entity\LabelSystem\LabelProfile', inversedBy: 'attachments')]
|
||||
#[ORM\ManyToOne(targetEntity: \App\Entity\LabelSystem\LabelProfile::class, inversedBy: 'attachments')]
|
||||
#[ORM\JoinColumn(name: 'element_id', nullable: false, onDelete: 'CASCADE')]
|
||||
protected ?AttachmentContainingDBElement $element = null;
|
||||
}
|
||||
|
|
|
@ -33,12 +33,12 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
|||
#[ORM\Entity]
|
||||
class ManufacturerAttachment extends Attachment
|
||||
{
|
||||
public const ALLOWED_ELEMENT_CLASS = Manufacturer::class;
|
||||
final public const ALLOWED_ELEMENT_CLASS = Manufacturer::class;
|
||||
|
||||
/**
|
||||
* @var Manufacturer|null the element this attachment is associated with
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: 'App\Entity\Parts\Manufacturer', inversedBy: 'attachments')]
|
||||
#[ORM\ManyToOne(targetEntity: \App\Entity\Parts\Manufacturer::class, inversedBy: 'attachments')]
|
||||
#[ORM\JoinColumn(name: 'element_id', nullable: false, onDelete: 'CASCADE')]
|
||||
protected ?AttachmentContainingDBElement $element = null;
|
||||
}
|
||||
|
|
|
@ -34,11 +34,11 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
|||
#[ORM\Entity]
|
||||
class MeasurementUnitAttachment extends Attachment
|
||||
{
|
||||
public const ALLOWED_ELEMENT_CLASS = MeasurementUnit::class;
|
||||
final public const ALLOWED_ELEMENT_CLASS = MeasurementUnit::class;
|
||||
/**
|
||||
* @var Manufacturer|null the element this attachment is associated with
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: 'App\Entity\Parts\MeasurementUnit', inversedBy: 'attachments')]
|
||||
#[ORM\ManyToOne(targetEntity: \App\Entity\Parts\MeasurementUnit::class, inversedBy: 'attachments')]
|
||||
#[ORM\JoinColumn(name: 'element_id', nullable: false, onDelete: 'CASCADE')]
|
||||
protected ?AttachmentContainingDBElement $element = null;
|
||||
}
|
||||
|
|
|
@ -33,11 +33,11 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
|||
#[ORM\Entity]
|
||||
class PartAttachment extends Attachment
|
||||
{
|
||||
public const ALLOWED_ELEMENT_CLASS = Part::class;
|
||||
final public const ALLOWED_ELEMENT_CLASS = Part::class;
|
||||
/**
|
||||
* @var Part the element this attachment is associated with
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: 'App\Entity\Parts\Part', inversedBy: 'attachments')]
|
||||
#[ORM\ManyToOne(targetEntity: \App\Entity\Parts\Part::class, inversedBy: 'attachments')]
|
||||
#[ORM\JoinColumn(name: 'element_id', nullable: false, onDelete: 'CASCADE')]
|
||||
protected ?AttachmentContainingDBElement $element = null;
|
||||
}
|
||||
|
|
|
@ -33,11 +33,11 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
|||
#[ORM\Entity]
|
||||
class ProjectAttachment extends Attachment
|
||||
{
|
||||
public const ALLOWED_ELEMENT_CLASS = Project::class;
|
||||
final public const ALLOWED_ELEMENT_CLASS = Project::class;
|
||||
/**
|
||||
* @var Project|null the element this attachment is associated with
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: 'App\Entity\ProjectSystem\Project', inversedBy: 'attachments')]
|
||||
#[ORM\ManyToOne(targetEntity: \App\Entity\ProjectSystem\Project::class, inversedBy: 'attachments')]
|
||||
#[ORM\JoinColumn(name: 'element_id', nullable: false, onDelete: 'CASCADE')]
|
||||
protected ?AttachmentContainingDBElement $element = null;
|
||||
}
|
||||
|
|
|
@ -33,12 +33,12 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
|||
#[ORM\Entity]
|
||||
class StorelocationAttachment extends Attachment
|
||||
{
|
||||
public const ALLOWED_ELEMENT_CLASS = Storelocation::class;
|
||||
final public const ALLOWED_ELEMENT_CLASS = Storelocation::class;
|
||||
|
||||
/**
|
||||
* @var Storelocation|null the element this attachment is associated with
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: 'App\Entity\Parts\Storelocation', inversedBy: 'attachments')]
|
||||
#[ORM\ManyToOne(targetEntity: \App\Entity\Parts\Storelocation::class, inversedBy: 'attachments')]
|
||||
#[ORM\JoinColumn(name: 'element_id', nullable: false, onDelete: 'CASCADE')]
|
||||
protected ?AttachmentContainingDBElement $element = null;
|
||||
}
|
||||
|
|
|
@ -33,12 +33,12 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
|||
#[ORM\Entity]
|
||||
class SupplierAttachment extends Attachment
|
||||
{
|
||||
public const ALLOWED_ELEMENT_CLASS = Supplier::class;
|
||||
final public const ALLOWED_ELEMENT_CLASS = Supplier::class;
|
||||
|
||||
/**
|
||||
* @var Supplier|null the element this attachment is associated with
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: 'App\Entity\Parts\Supplier', inversedBy: 'attachments')]
|
||||
#[ORM\ManyToOne(targetEntity: \App\Entity\Parts\Supplier::class, inversedBy: 'attachments')]
|
||||
#[ORM\JoinColumn(name: 'element_id', nullable: false, onDelete: 'CASCADE')]
|
||||
protected ?AttachmentContainingDBElement $element = null;
|
||||
}
|
||||
|
|
|
@ -33,12 +33,12 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
|||
#[ORM\Entity]
|
||||
class UserAttachment extends Attachment
|
||||
{
|
||||
public const ALLOWED_ELEMENT_CLASS = User::class;
|
||||
final public const ALLOWED_ELEMENT_CLASS = User::class;
|
||||
|
||||
/**
|
||||
* @var User|null the element this attachment is associated with
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: 'App\Entity\UserSystem\User', inversedBy: 'attachments')]
|
||||
#[ORM\ManyToOne(targetEntity: \App\Entity\UserSystem\User::class, inversedBy: 'attachments')]
|
||||
#[ORM\JoinColumn(name: 'element_id', nullable: false, onDelete: 'CASCADE')]
|
||||
protected ?AttachmentContainingDBElement $element = null;
|
||||
}
|
||||
|
|
|
@ -35,8 +35,8 @@ use Symfony\Component\Serializer\Annotation\Groups;
|
|||
* 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.
|
||||
*/
|
||||
#[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')]
|
||||
#[DiscriminatorMap(typeProperty: 'type', mapping: ['attachment_type' => \App\Entity\Attachments\AttachmentType::class, 'attachment' => \App\Entity\Attachments\Attachment::class, 'attachment_type_attachment' => \App\Entity\Attachments\AttachmentTypeAttachment::class, 'category_attachment' => \App\Entity\Attachments\CategoryAttachment::class, 'currency_attachment' => \App\Entity\Attachments\CurrencyAttachment::class, 'footprint_attachment' => \App\Entity\Attachments\FootprintAttachment::class, 'group_attachment' => \App\Entity\Attachments\GroupAttachment::class, 'label_attachment' => \App\Entity\Attachments\LabelAttachment::class, 'manufacturer_attachment' => \App\Entity\Attachments\ManufacturerAttachment::class, 'measurement_unit_attachment' => \App\Entity\Attachments\MeasurementUnitAttachment::class, 'part_attachment' => \App\Entity\Attachments\PartAttachment::class, 'project_attachment' => \App\Entity\Attachments\ProjectAttachment::class, 'storelocation_attachment' => \App\Entity\Attachments\StorelocationAttachment::class, 'supplier_attachment' => \App\Entity\Attachments\SupplierAttachment::class, 'user_attachment' => \App\Entity\Attachments\UserAttachment::class, 'category' => \App\Entity\Parts\Category::class, 'project' => \App\Entity\ProjectSystem\Project::class, 'project_bom_entry' => \App\Entity\ProjectSystem\ProjectBOMEntry::class, 'footprint' => \App\Entity\Parts\Footprint::class, 'group' => \App\Entity\UserSystem\Group::class, 'manufacturer' => \App\Entity\Parts\Manufacturer::class, 'orderdetail' => \App\Entity\PriceInformations\Orderdetail::class, 'part' => \App\Entity\Parts\Part::class, 'pricedetail' => 'App\Entity\PriceInformation\Pricedetail', 'storelocation' => \App\Entity\Parts\Storelocation::class, 'part_lot' => \App\Entity\Parts\PartLot::class, 'currency' => \App\Entity\PriceInformations\Currency::class, 'measurement_unit' => \App\Entity\Parts\MeasurementUnit::class, 'parameter' => 'App\Entity\Parts\AbstractParameter', 'supplier' => \App\Entity\Parts\Supplier::class, 'user' => \App\Entity\UserSystem\User::class])]
|
||||
#[ORM\MappedSuperclass(repositoryClass: \App\Repository\DBElementRepository::class)]
|
||||
abstract class AbstractDBElement implements JsonSerializable
|
||||
{
|
||||
/** @var int|null The Identification number for this part. This value is unique for the element in this table.
|
||||
|
|
|
@ -33,7 +33,7 @@ use Symfony\Component\Validator\Constraints as Assert;
|
|||
*/
|
||||
#[ORM\MappedSuperclass(repositoryClass: 'App\Repository\NamedDBElement')]
|
||||
#[ORM\HasLifecycleCallbacks]
|
||||
abstract class AbstractNamedDBElement extends AbstractDBElement implements NamedElementInterface, TimeStampableInterface
|
||||
abstract class AbstractNamedDBElement extends AbstractDBElement implements NamedElementInterface, TimeStampableInterface, \Stringable
|
||||
{
|
||||
use TimestampTrait;
|
||||
|
||||
|
@ -51,7 +51,7 @@ abstract class AbstractNamedDBElement extends AbstractDBElement implements Named
|
|||
*
|
||||
******************************************************************************/
|
||||
|
||||
public function __toString()
|
||||
public function __toString(): string
|
||||
{
|
||||
return $this->getName();
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ use Symfony\Component\Serializer\Annotation\Groups;
|
|||
/**
|
||||
* Class PartsContainingDBElement.
|
||||
*/
|
||||
#[ORM\MappedSuperclass(repositoryClass: 'App\Repository\AbstractPartsContainingRepository')]
|
||||
#[ORM\MappedSuperclass(repositoryClass: \App\Repository\AbstractPartsContainingRepository::class)]
|
||||
abstract class AbstractPartsContainingDBElement extends AbstractStructuralDBElement
|
||||
{
|
||||
#[Groups(['full'])]
|
||||
|
|
|
@ -46,8 +46,8 @@ use Symfony\Component\Serializer\Annotation\Groups;
|
|||
*
|
||||
*/
|
||||
#[UniqueEntity(fields: ['name', 'parent'], ignoreNull: false, message: 'structural.entity.unique_name')]
|
||||
#[ORM\MappedSuperclass(repositoryClass: 'App\Repository\StructuralDBElementRepository')]
|
||||
#[ORM\EntityListeners(['App\EntityListeners\TreeCacheInvalidationListener'])]
|
||||
#[ORM\MappedSuperclass(repositoryClass: \App\Repository\StructuralDBElementRepository::class)]
|
||||
#[ORM\EntityListeners([\App\EntityListeners\TreeCacheInvalidationListener::class])]
|
||||
abstract class AbstractStructuralDBElement extends AttachmentContainingDBElement
|
||||
{
|
||||
use ParametersTrait;
|
||||
|
@ -105,7 +105,6 @@ abstract class AbstractStructuralDBElement extends AttachmentContainingDBElement
|
|||
parent::__construct();
|
||||
$this->children = new ArrayCollection();
|
||||
$this->parameters = new ArrayCollection();
|
||||
$this->parent = null;
|
||||
}
|
||||
|
||||
public function __clone()
|
||||
|
@ -141,11 +140,11 @@ abstract class AbstractStructuralDBElement extends AttachmentContainingDBElement
|
|||
|
||||
//Check if both elements compared, are from the same type
|
||||
// (we have to check inheritance, or we get exceptions when using doctrine entities (they have a proxy type):
|
||||
if (!is_a($another_element, $class_name) && !is_a($this, get_class($another_element))) {
|
||||
if (!$another_element instanceof $class_name && !is_a($this, $another_element::class)) {
|
||||
throw new InvalidArgumentException('isChildOf() only works for objects of the same type!');
|
||||
}
|
||||
|
||||
if (null === $this->getParent()) { // this is the root node
|
||||
if (!$this->getParent() instanceof \App\Entity\Base\AbstractStructuralDBElement) { // this is the root node
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -170,7 +169,7 @@ abstract class AbstractStructuralDBElement extends AttachmentContainingDBElement
|
|||
*/
|
||||
public function isRoot(): bool
|
||||
{
|
||||
return null === $this->parent;
|
||||
return !$this->parent instanceof \App\Entity\Base\AbstractStructuralDBElement;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
|
@ -213,9 +212,9 @@ abstract class AbstractStructuralDBElement extends AttachmentContainingDBElement
|
|||
/*
|
||||
* Only check for nodes that have a parent. In the other cases zero is correct.
|
||||
*/
|
||||
if (0 === $this->level && null !== $this->parent) {
|
||||
if (0 === $this->level && $this->parent instanceof \App\Entity\Base\AbstractStructuralDBElement) {
|
||||
$element = $this->parent;
|
||||
while (null !== $element) {
|
||||
while ($element instanceof \App\Entity\Base\AbstractStructuralDBElement) {
|
||||
/** @var AbstractStructuralDBElement $element */
|
||||
$element = $element->parent;
|
||||
++$this->level;
|
||||
|
@ -234,14 +233,14 @@ abstract class AbstractStructuralDBElement extends AttachmentContainingDBElement
|
|||
*/
|
||||
public function getFullPath(string $delimiter = self::PATH_DELIMITER_ARROW): string
|
||||
{
|
||||
if (empty($this->full_path_strings)) {
|
||||
if ($this->full_path_strings === []) {
|
||||
$this->full_path_strings = [];
|
||||
$this->full_path_strings[] = $this->getName();
|
||||
$element = $this;
|
||||
|
||||
$overflow = 20; //We only allow 20 levels depth
|
||||
|
||||
while (null !== $element->parent && $overflow >= 0) {
|
||||
while ($element->parent instanceof \App\Entity\Base\AbstractStructuralDBElement && $overflow >= 0) {
|
||||
$element = $element->parent;
|
||||
$this->full_path_strings[] = $element->getName();
|
||||
//Decrement to prevent mem overflow.
|
||||
|
@ -328,7 +327,7 @@ abstract class AbstractStructuralDBElement extends AttachmentContainingDBElement
|
|||
$this->parent = $new_parent;
|
||||
|
||||
//Add this element as child to the new parent
|
||||
if (null !== $new_parent) {
|
||||
if ($new_parent instanceof \App\Entity\Base\AbstractStructuralDBElement) {
|
||||
$new_parent->getChildren()->add($this);
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ trait MasterAttachmentTrait
|
|||
* @var Attachment|null
|
||||
*/
|
||||
#[Assert\Expression('value == null or value.isPicture()', message: 'part.master_attachment.must_be_picture')]
|
||||
#[ORM\ManyToOne(targetEntity: 'App\Entity\Attachments\Attachment')]
|
||||
#[ORM\ManyToOne(targetEntity: \App\Entity\Attachments\Attachment::class)]
|
||||
#[ORM\JoinColumn(name: 'id_preview_attachment', onDelete: 'SET NULL')]
|
||||
protected ?Attachment $master_picture_attachment = null;
|
||||
|
||||
|
|
|
@ -47,11 +47,11 @@ use Symfony\Component\Validator\Constraints as Assert;
|
|||
#[ORM\Embeddable]
|
||||
class LabelOptions
|
||||
{
|
||||
public const BARCODE_TYPES = ['none', /*'ean8',*/ 'qr', 'code39', 'datamatrix', 'code93', 'code128'];
|
||||
public const SUPPORTED_ELEMENTS = ['part', 'part_lot', 'storelocation'];
|
||||
public const PICTURE_TYPES = ['none', 'element_picture', 'main_attachment'];
|
||||
final public const BARCODE_TYPES = ['none', /*'ean8',*/ 'qr', 'code39', 'datamatrix', 'code93', 'code128'];
|
||||
final public const SUPPORTED_ELEMENTS = ['part', 'part_lot', 'storelocation'];
|
||||
final public const PICTURE_TYPES = ['none', 'element_picture', 'main_attachment'];
|
||||
|
||||
public const LINES_MODES = ['html', 'twig'];
|
||||
final public const LINES_MODES = ['html', 'twig'];
|
||||
|
||||
/**
|
||||
* @var float The page size of the label in mm
|
||||
|
@ -111,9 +111,6 @@ class LabelOptions
|
|||
return $this->width;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return LabelOptions
|
||||
*/
|
||||
public function setWidth(float $width): self
|
||||
{
|
||||
$this->width = $width;
|
||||
|
@ -126,9 +123,6 @@ class LabelOptions
|
|||
return $this->height;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return LabelOptions
|
||||
*/
|
||||
public function setHeight(float $height): self
|
||||
{
|
||||
$this->height = $height;
|
||||
|
@ -141,9 +135,6 @@ class LabelOptions
|
|||
return $this->barcode_type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return LabelOptions
|
||||
*/
|
||||
public function setBarcodeType(string $barcode_type): self
|
||||
{
|
||||
$this->barcode_type = $barcode_type;
|
||||
|
@ -156,9 +147,6 @@ class LabelOptions
|
|||
return $this->picture_type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return LabelOptions
|
||||
*/
|
||||
public function setPictureType(string $picture_type): self
|
||||
{
|
||||
$this->picture_type = $picture_type;
|
||||
|
@ -171,9 +159,6 @@ class LabelOptions
|
|||
return $this->supported_element;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return LabelOptions
|
||||
*/
|
||||
public function setSupportedElement(string $supported_element): self
|
||||
{
|
||||
$this->supported_element = $supported_element;
|
||||
|
@ -186,9 +171,6 @@ class LabelOptions
|
|||
return $this->lines;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return LabelOptions
|
||||
*/
|
||||
public function setLines(string $lines): self
|
||||
{
|
||||
$this->lines = $lines;
|
||||
|
@ -204,9 +186,6 @@ class LabelOptions
|
|||
return $this->additional_css;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return LabelOptions
|
||||
*/
|
||||
public function setAdditionalCss(string $additional_css): self
|
||||
{
|
||||
$this->additional_css = $additional_css;
|
||||
|
@ -219,9 +198,6 @@ class LabelOptions
|
|||
return $this->lines_mode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return LabelOptions
|
||||
*/
|
||||
public function setLinesMode(string $lines_mode): self
|
||||
{
|
||||
$this->lines_mode = $lines_mode;
|
||||
|
|
|
@ -49,15 +49,15 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
|||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
#[UniqueEntity(['name', 'options.supported_element'])]
|
||||
#[ORM\Entity(repositoryClass: 'App\Repository\LabelProfileRepository')]
|
||||
#[ORM\EntityListeners(['App\EntityListeners\TreeCacheInvalidationListener'])]
|
||||
#[ORM\Entity(repositoryClass: \App\Repository\LabelProfileRepository::class)]
|
||||
#[ORM\EntityListeners([\App\EntityListeners\TreeCacheInvalidationListener::class])]
|
||||
#[ORM\Table(name: 'label_profiles')]
|
||||
class LabelProfile extends AttachmentContainingDBElement
|
||||
{
|
||||
/**
|
||||
* @var Collection<int, LabelAttachment>
|
||||
*/
|
||||
#[ORM\OneToMany(targetEntity: 'App\Entity\Attachments\LabelAttachment', mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
|
||||
#[ORM\OneToMany(targetEntity: \App\Entity\Attachments\LabelAttachment::class, mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
|
||||
#[ORM\OrderBy(['name' => 'ASC'])]
|
||||
protected Collection $attachments;
|
||||
|
||||
|
@ -126,8 +126,6 @@ class LabelProfile extends AttachmentContainingDBElement
|
|||
|
||||
/**
|
||||
* Sets the show in dropdown menu.
|
||||
*
|
||||
* @return LabelProfile
|
||||
*/
|
||||
public function setShowInDropdown(bool $show_in_dropdown): self
|
||||
{
|
||||
|
|
|
@ -61,14 +61,14 @@ use App\Repository\LogEntryRepository;
|
|||
#[ORM\Index(columns: ['datetime'], name: 'log_idx_datetime')]
|
||||
abstract class AbstractLogEntry extends AbstractDBElement
|
||||
{
|
||||
public const LEVEL_EMERGENCY = 0;
|
||||
public const LEVEL_ALERT = 1;
|
||||
public const LEVEL_CRITICAL = 2;
|
||||
public const LEVEL_ERROR = 3;
|
||||
public const LEVEL_WARNING = 4;
|
||||
public const LEVEL_NOTICE = 5;
|
||||
public const LEVEL_INFO = 6;
|
||||
public const LEVEL_DEBUG = 7;
|
||||
final public const LEVEL_EMERGENCY = 0;
|
||||
final public const LEVEL_ALERT = 1;
|
||||
final public const LEVEL_CRITICAL = 2;
|
||||
final public const LEVEL_ERROR = 3;
|
||||
final public const LEVEL_WARNING = 4;
|
||||
final public const LEVEL_NOTICE = 5;
|
||||
final public const LEVEL_INFO = 6;
|
||||
final public const LEVEL_DEBUG = 7;
|
||||
|
||||
protected const TARGET_TYPE_NONE = 0;
|
||||
protected const TARGET_TYPE_USER = 1;
|
||||
|
@ -129,7 +129,7 @@ abstract class AbstractLogEntry extends AbstractDBElement
|
|||
|
||||
/** @var User|null The user which has caused this log entry
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: 'App\Entity\UserSystem\User', fetch: 'EAGER')]
|
||||
#[ORM\ManyToOne(targetEntity: \App\Entity\UserSystem\User::class, fetch: 'EAGER')]
|
||||
#[ORM\JoinColumn(name: 'id_user', onDelete: 'SET NULL')]
|
||||
protected ?User $user = null;
|
||||
|
||||
|
@ -147,7 +147,7 @@ abstract class AbstractLogEntry extends AbstractDBElement
|
|||
/** @var int The priority level of the associated level. 0 is highest, 7 lowest
|
||||
*/
|
||||
#[ORM\Column(type: 'tinyint', name: 'level')]
|
||||
protected int $level;
|
||||
protected int $level = self::LEVEL_WARNING;
|
||||
|
||||
/** @var int The ID of the element targeted by this event
|
||||
*/
|
||||
|
@ -173,7 +173,6 @@ abstract class AbstractLogEntry extends AbstractDBElement
|
|||
public function __construct()
|
||||
{
|
||||
$this->timestamp = new DateTime();
|
||||
$this->level = self::LEVEL_WARNING;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -214,7 +213,6 @@ abstract class AbstractLogEntry extends AbstractDBElement
|
|||
* Marks this log entry as a CLI entry, and set the username of the CLI user.
|
||||
* This removes the association to a user object in database, as CLI users are not really related to logged in
|
||||
* Part-DB users.
|
||||
* @param string $cli_username
|
||||
* @return $this
|
||||
*/
|
||||
public function setCLIUsername(string $cli_username): self
|
||||
|
@ -372,14 +370,14 @@ abstract class AbstractLogEntry extends AbstractDBElement
|
|||
*/
|
||||
public function setTargetElement(?AbstractDBElement $element): self
|
||||
{
|
||||
if (null === $element) {
|
||||
if (!$element instanceof \App\Entity\Base\AbstractDBElement) {
|
||||
$this->target_id = 0;
|
||||
$this->target_type = self::TARGET_TYPE_NONE;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
$this->target_type = static::targetTypeClassToID(get_class($element));
|
||||
$this->target_type = static::targetTypeClassToID($element::class);
|
||||
$this->target_id = $element->getID();
|
||||
|
||||
return $this;
|
||||
|
|
|
@ -93,11 +93,9 @@ class CollectionElementDeleted extends AbstractLogEntry implements LogWithEventU
|
|||
public function __construct(AbstractDBElement $changed_element, string $collection_name, AbstractDBElement $deletedElement)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->level = self::LEVEL_INFO;
|
||||
$this->setTargetElement($changed_element);
|
||||
$this->extra['n'] = $collection_name;
|
||||
$this->extra['c'] = self::targetTypeClassToID(get_class($deletedElement));
|
||||
$this->extra['c'] = self::targetTypeClassToID($deletedElement::class);
|
||||
$this->extra['i'] = $deletedElement->getID();
|
||||
if ($deletedElement instanceof NamedElementInterface) {
|
||||
$this->extra['o'] = $deletedElement->getName();
|
||||
|
@ -141,8 +139,6 @@ class CollectionElementDeleted extends AbstractLogEntry implements LogWithEventU
|
|||
/**
|
||||
* This functions maps an abstract class name derived from the extra c element to an instantiable class name (based on the target element of this log entry).
|
||||
* For example if the target element is a part and the extra c element is "App\Entity\Attachments\Attachment", this function will return "App\Entity\Attachments\PartAttachment".
|
||||
* @param string $abstract_class
|
||||
* @return string
|
||||
*/
|
||||
private function resolveAbstractClassToInstantiableClass(string $abstract_class): string
|
||||
{
|
||||
|
|
|
@ -26,9 +26,9 @@ use Doctrine\ORM\Mapping as ORM;
|
|||
#[ORM\Entity]
|
||||
class PartStockChangedLogEntry extends AbstractLogEntry
|
||||
{
|
||||
public const TYPE_ADD = "add";
|
||||
public const TYPE_WITHDRAW = "withdraw";
|
||||
public const TYPE_MOVE = "move";
|
||||
final public const TYPE_ADD = "add";
|
||||
final public const TYPE_WITHDRAW = "withdraw";
|
||||
final public const TYPE_MOVE = "move";
|
||||
|
||||
protected string $typeString = 'part_stock_changed';
|
||||
|
||||
|
@ -68,7 +68,7 @@ class PartStockChangedLogEntry extends AbstractLogEntry
|
|||
$this->extra['c'] = mb_strimwidth($comment, 0, self::COMMENT_MAX_LENGTH, '...');
|
||||
}
|
||||
|
||||
if ($move_to_target) {
|
||||
if ($move_to_target instanceof \App\Entity\Parts\PartLot) {
|
||||
if ($type !== self::TYPE_MOVE) {
|
||||
throw new \InvalidArgumentException('The move_to_target parameter can only be set if the type is "move"!');
|
||||
}
|
||||
|
@ -130,7 +130,6 @@ class PartStockChangedLogEntry extends AbstractLogEntry
|
|||
|
||||
/**
|
||||
* Returns the old stock of the lot.
|
||||
* @return float
|
||||
*/
|
||||
public function getOldStock(): float
|
||||
{
|
||||
|
@ -139,7 +138,6 @@ class PartStockChangedLogEntry extends AbstractLogEntry
|
|||
|
||||
/**
|
||||
* Returns the new stock of the lot.
|
||||
* @return float
|
||||
*/
|
||||
public function getNewStock(): float
|
||||
{
|
||||
|
@ -148,7 +146,6 @@ class PartStockChangedLogEntry extends AbstractLogEntry
|
|||
|
||||
/**
|
||||
* Returns the new total instock of the part.
|
||||
* @return float
|
||||
*/
|
||||
public function getNewTotalPartInstock(): float
|
||||
{
|
||||
|
@ -157,7 +154,6 @@ class PartStockChangedLogEntry extends AbstractLogEntry
|
|||
|
||||
/**
|
||||
* Returns the comment associated with the change.
|
||||
* @return string
|
||||
*/
|
||||
public function getComment(): string
|
||||
{
|
||||
|
@ -166,7 +162,6 @@ class PartStockChangedLogEntry extends AbstractLogEntry
|
|||
|
||||
/**
|
||||
* Gets the difference between the old and the new stock value of the lot as a positive number.
|
||||
* @return float
|
||||
*/
|
||||
public function getChangeAmount(): float
|
||||
{
|
||||
|
@ -175,7 +170,6 @@ class PartStockChangedLogEntry extends AbstractLogEntry
|
|||
|
||||
/**
|
||||
* Returns the target lot ID (where the instock was moved to) if the type is TYPE_MOVE.
|
||||
* @return int|null
|
||||
*/
|
||||
public function getMoveToTargetID(): ?int
|
||||
{
|
||||
|
@ -184,39 +178,27 @@ class PartStockChangedLogEntry extends AbstractLogEntry
|
|||
|
||||
/**
|
||||
* Converts the human-readable type (TYPE_* consts) to the version stored in DB
|
||||
* @param string $type
|
||||
* @return string
|
||||
*/
|
||||
protected function typeToShortType(string $type): string
|
||||
{
|
||||
switch ($type) {
|
||||
case self::TYPE_ADD:
|
||||
return 'a';
|
||||
case self::TYPE_WITHDRAW:
|
||||
return 'w';
|
||||
case self::TYPE_MOVE:
|
||||
return 'm';
|
||||
default:
|
||||
throw new \InvalidArgumentException('Invalid type: '.$type);
|
||||
}
|
||||
return match ($type) {
|
||||
self::TYPE_ADD => 'a',
|
||||
self::TYPE_WITHDRAW => 'w',
|
||||
self::TYPE_MOVE => 'm',
|
||||
default => throw new \InvalidArgumentException('Invalid type: '.$type),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the short type stored in DB to the human-readable type (TYPE_* consts).
|
||||
* @param string $short_type
|
||||
* @return string
|
||||
*/
|
||||
protected function shortTypeToType(string $short_type): string
|
||||
{
|
||||
switch ($short_type) {
|
||||
case 'a':
|
||||
return self::TYPE_ADD;
|
||||
case 'w':
|
||||
return self::TYPE_WITHDRAW;
|
||||
case 'm':
|
||||
return self::TYPE_MOVE;
|
||||
default:
|
||||
throw new \InvalidArgumentException('Invalid short type: '.$short_type);
|
||||
}
|
||||
return match ($short_type) {
|
||||
'a' => self::TYPE_ADD,
|
||||
'w' => self::TYPE_WITHDRAW,
|
||||
'm' => self::TYPE_MOVE,
|
||||
default => throw new \InvalidArgumentException('Invalid short type: '.$short_type),
|
||||
};
|
||||
}
|
||||
}
|
|
@ -54,7 +54,7 @@ use Symfony\Component\HttpFoundation\IpUtils;
|
|||
#[ORM\Entity]
|
||||
class SecurityEventLogEntry extends AbstractLogEntry
|
||||
{
|
||||
public const SECURITY_TYPE_MAPPING = [
|
||||
final public const SECURITY_TYPE_MAPPING = [
|
||||
0 => SecurityEvents::PASSWORD_CHANGED,
|
||||
1 => SecurityEvents::PASSWORD_RESET,
|
||||
2 => SecurityEvents::BACKUP_KEYS_RESET,
|
||||
|
|
|
@ -51,7 +51,7 @@ use Symfony\Component\Validator\Constraints as Assert;
|
|||
|
||||
use function sprintf;
|
||||
|
||||
#[ORM\Entity(repositoryClass: 'App\Repository\ParameterRepository')]
|
||||
#[ORM\Entity(repositoryClass: \App\Repository\ParameterRepository::class)]
|
||||
#[ORM\InheritanceType('SINGLE_TABLE')]
|
||||
#[ORM\DiscriminatorColumn(name: 'type', type: 'smallint')]
|
||||
#[ORM\DiscriminatorMap([0 => 'CategoryParameter', 1 => 'CurrencyParameter', 2 => 'ProjectParameter', 3 => 'FootprintParameter', 4 => 'GroupParameter', 5 => 'ManufacturerParameter', 6 => 'MeasurementUnitParameter', 7 => 'PartParameter', 8 => 'StorelocationParameter', 9 => 'SupplierParameter', 10 => 'AttachmentTypeParameter'])]
|
||||
|
@ -187,7 +187,7 @@ abstract class AbstractParameter extends AbstractNamedDBElement
|
|||
$str .= ')';
|
||||
}
|
||||
|
||||
if ($this->value_text) {
|
||||
if ($this->value_text !== '' && $this->value_text !== '0') {
|
||||
$str .= ' ['.$this->value_text.']';
|
||||
}
|
||||
|
||||
|
@ -317,7 +317,6 @@ abstract class AbstractParameter extends AbstractNamedDBElement
|
|||
/**
|
||||
* Sets the typical value of this property.
|
||||
*
|
||||
* @param float|null $value_typical
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
|
|
|
@ -47,14 +47,14 @@ use Doctrine\ORM\Mapping as ORM;
|
|||
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
||||
|
||||
#[UniqueEntity(fields: ['name', 'group', 'element'])]
|
||||
#[ORM\Entity(repositoryClass: 'App\Repository\ParameterRepository')]
|
||||
#[ORM\Entity(repositoryClass: \App\Repository\ParameterRepository::class)]
|
||||
class AttachmentTypeParameter extends AbstractParameter
|
||||
{
|
||||
public const ALLOWED_ELEMENT_CLASS = AttachmentType::class;
|
||||
final public const ALLOWED_ELEMENT_CLASS = AttachmentType::class;
|
||||
/**
|
||||
* @var AttachmentType the element this para is associated with
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: 'App\Entity\Attachments\AttachmentType', inversedBy: 'parameters')]
|
||||
#[ORM\ManyToOne(targetEntity: \App\Entity\Attachments\AttachmentType::class, inversedBy: 'parameters')]
|
||||
#[ORM\JoinColumn(name: 'element_id', nullable: false, onDelete: 'CASCADE')]
|
||||
protected ?AbstractDBElement $element = null;
|
||||
}
|
||||
|
|
|
@ -47,14 +47,14 @@ use Doctrine\ORM\Mapping as ORM;
|
|||
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
||||
|
||||
#[UniqueEntity(fields: ['name', 'group', 'element'])]
|
||||
#[ORM\Entity(repositoryClass: 'App\Repository\ParameterRepository')]
|
||||
#[ORM\Entity(repositoryClass: \App\Repository\ParameterRepository::class)]
|
||||
class CategoryParameter extends AbstractParameter
|
||||
{
|
||||
public const ALLOWED_ELEMENT_CLASS = Category::class;
|
||||
final public const ALLOWED_ELEMENT_CLASS = Category::class;
|
||||
/**
|
||||
* @var Category the element this para is associated with
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: 'App\Entity\Parts\Category', inversedBy: 'parameters')]
|
||||
#[ORM\ManyToOne(targetEntity: \App\Entity\Parts\Category::class, inversedBy: 'parameters')]
|
||||
#[ORM\JoinColumn(name: 'element_id', nullable: false, onDelete: 'CASCADE')]
|
||||
protected ?AbstractDBElement $element = null;
|
||||
}
|
||||
|
|
|
@ -50,15 +50,15 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
|||
* An attachment attached to a category element.
|
||||
*/
|
||||
#[UniqueEntity(fields: ['name', 'group', 'element'])]
|
||||
#[ORM\Entity(repositoryClass: 'App\Repository\ParameterRepository')]
|
||||
#[ORM\Entity(repositoryClass: \App\Repository\ParameterRepository::class)]
|
||||
class CurrencyParameter extends AbstractParameter
|
||||
{
|
||||
public const ALLOWED_ELEMENT_CLASS = Currency::class;
|
||||
final public const ALLOWED_ELEMENT_CLASS = Currency::class;
|
||||
|
||||
/**
|
||||
* @var Currency the element this para is associated with
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: 'App\Entity\PriceInformations\Currency', inversedBy: 'parameters')]
|
||||
#[ORM\ManyToOne(targetEntity: \App\Entity\PriceInformations\Currency::class, inversedBy: 'parameters')]
|
||||
#[ORM\JoinColumn(name: 'element_id', nullable: false, onDelete: 'CASCADE')]
|
||||
protected ?AbstractDBElement $element = null;
|
||||
}
|
||||
|
|
|
@ -47,15 +47,15 @@ use Doctrine\ORM\Mapping as ORM;
|
|||
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
||||
|
||||
#[UniqueEntity(fields: ['name', 'group', 'element'])]
|
||||
#[ORM\Entity(repositoryClass: 'App\Repository\ParameterRepository')]
|
||||
#[ORM\Entity(repositoryClass: \App\Repository\ParameterRepository::class)]
|
||||
class FootprintParameter extends AbstractParameter
|
||||
{
|
||||
public const ALLOWED_ELEMENT_CLASS = Footprint::class;
|
||||
final public const ALLOWED_ELEMENT_CLASS = Footprint::class;
|
||||
|
||||
/**
|
||||
* @var Footprint the element this para is associated with
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: 'App\Entity\Parts\Footprint', inversedBy: 'parameters')]
|
||||
#[ORM\ManyToOne(targetEntity: \App\Entity\Parts\Footprint::class, inversedBy: 'parameters')]
|
||||
#[ORM\JoinColumn(name: 'element_id', nullable: false, onDelete: 'CASCADE')]
|
||||
protected ?AbstractDBElement $element = null;
|
||||
}
|
||||
|
|
|
@ -47,15 +47,15 @@ use Doctrine\ORM\Mapping as ORM;
|
|||
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
||||
|
||||
#[UniqueEntity(fields: ['name', 'group', 'element'])]
|
||||
#[ORM\Entity(repositoryClass: 'App\Repository\ParameterRepository')]
|
||||
#[ORM\Entity(repositoryClass: \App\Repository\ParameterRepository::class)]
|
||||
class GroupParameter extends AbstractParameter
|
||||
{
|
||||
public const ALLOWED_ELEMENT_CLASS = Group::class;
|
||||
final public const ALLOWED_ELEMENT_CLASS = Group::class;
|
||||
|
||||
/**
|
||||
* @var Group the element this para is associated with
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: 'App\Entity\UserSystem\Group', inversedBy: 'parameters')]
|
||||
#[ORM\ManyToOne(targetEntity: \App\Entity\UserSystem\Group::class, inversedBy: 'parameters')]
|
||||
#[ORM\JoinColumn(name: 'element_id', nullable: false, onDelete: 'CASCADE')]
|
||||
protected ?AbstractDBElement $element = null;
|
||||
}
|
||||
|
|
|
@ -47,15 +47,15 @@ use Doctrine\ORM\Mapping as ORM;
|
|||
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
||||
|
||||
#[UniqueEntity(fields: ['name', 'group', 'element'])]
|
||||
#[ORM\Entity(repositoryClass: 'App\Repository\ParameterRepository')]
|
||||
#[ORM\Entity(repositoryClass: \App\Repository\ParameterRepository::class)]
|
||||
class ManufacturerParameter extends AbstractParameter
|
||||
{
|
||||
public const ALLOWED_ELEMENT_CLASS = Manufacturer::class;
|
||||
final public const ALLOWED_ELEMENT_CLASS = Manufacturer::class;
|
||||
|
||||
/**
|
||||
* @var Manufacturer the element this para is associated with
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: 'App\Entity\Parts\Manufacturer', inversedBy: 'parameters')]
|
||||
#[ORM\ManyToOne(targetEntity: \App\Entity\Parts\Manufacturer::class, inversedBy: 'parameters')]
|
||||
#[ORM\JoinColumn(name: 'element_id', nullable: false, onDelete: 'CASCADE')]
|
||||
protected ?AbstractDBElement $element = null;
|
||||
}
|
||||
|
|
|
@ -47,15 +47,15 @@ use Doctrine\ORM\Mapping as ORM;
|
|||
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
||||
|
||||
#[UniqueEntity(fields: ['name', 'group', 'element'])]
|
||||
#[ORM\Entity(repositoryClass: 'App\Repository\ParameterRepository')]
|
||||
#[ORM\Entity(repositoryClass: \App\Repository\ParameterRepository::class)]
|
||||
class MeasurementUnitParameter extends AbstractParameter
|
||||
{
|
||||
public const ALLOWED_ELEMENT_CLASS = MeasurementUnit::class;
|
||||
final public const ALLOWED_ELEMENT_CLASS = MeasurementUnit::class;
|
||||
|
||||
/**
|
||||
* @var MeasurementUnit the element this para is associated with
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: 'App\Entity\Parts\MeasurementUnit', inversedBy: 'parameters')]
|
||||
#[ORM\ManyToOne(targetEntity: \App\Entity\Parts\MeasurementUnit::class, inversedBy: 'parameters')]
|
||||
#[ORM\JoinColumn(name: 'element_id', nullable: false, onDelete: 'CASCADE')]
|
||||
protected ?AbstractDBElement $element = null;
|
||||
}
|
||||
|
|
|
@ -47,15 +47,15 @@ use Doctrine\ORM\Mapping as ORM;
|
|||
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
||||
|
||||
#[UniqueEntity(fields: ['name', 'group', 'element'])]
|
||||
#[ORM\Entity(repositoryClass: 'App\Repository\ParameterRepository')]
|
||||
#[ORM\Entity(repositoryClass: \App\Repository\ParameterRepository::class)]
|
||||
class PartParameter extends AbstractParameter
|
||||
{
|
||||
public const ALLOWED_ELEMENT_CLASS = Part::class;
|
||||
final public const ALLOWED_ELEMENT_CLASS = Part::class;
|
||||
|
||||
/**
|
||||
* @var Part the element this para is associated with
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: 'App\Entity\Parts\Part', inversedBy: 'parameters')]
|
||||
#[ORM\ManyToOne(targetEntity: \App\Entity\Parts\Part::class, inversedBy: 'parameters')]
|
||||
#[ORM\JoinColumn(name: 'element_id', nullable: false, onDelete: 'CASCADE')]
|
||||
protected ?AbstractDBElement $element = null;
|
||||
}
|
||||
|
|
|
@ -47,15 +47,15 @@ use Doctrine\ORM\Mapping as ORM;
|
|||
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
||||
|
||||
#[UniqueEntity(fields: ['name', 'group', 'element'])]
|
||||
#[ORM\Entity(repositoryClass: 'App\Repository\ParameterRepository')]
|
||||
#[ORM\Entity(repositoryClass: \App\Repository\ParameterRepository::class)]
|
||||
class ProjectParameter extends AbstractParameter
|
||||
{
|
||||
public const ALLOWED_ELEMENT_CLASS = Project::class;
|
||||
final public const ALLOWED_ELEMENT_CLASS = Project::class;
|
||||
|
||||
/**
|
||||
* @var Project the element this para is associated with
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: 'App\Entity\ProjectSystem\Project', inversedBy: 'parameters')]
|
||||
#[ORM\ManyToOne(targetEntity: \App\Entity\ProjectSystem\Project::class, inversedBy: 'parameters')]
|
||||
#[ORM\JoinColumn(name: 'element_id', nullable: false, onDelete: 'CASCADE')]
|
||||
protected ?AbstractDBElement $element = null;
|
||||
}
|
||||
|
|
|
@ -47,15 +47,15 @@ use Doctrine\ORM\Mapping as ORM;
|
|||
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
||||
|
||||
#[UniqueEntity(fields: ['name', 'group', 'element'])]
|
||||
#[ORM\Entity(repositoryClass: 'App\Repository\ParameterRepository')]
|
||||
#[ORM\Entity(repositoryClass: \App\Repository\ParameterRepository::class)]
|
||||
class StorelocationParameter extends AbstractParameter
|
||||
{
|
||||
public const ALLOWED_ELEMENT_CLASS = Storelocation::class;
|
||||
final public const ALLOWED_ELEMENT_CLASS = Storelocation::class;
|
||||
|
||||
/**
|
||||
* @var Storelocation the element this para is associated with
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: 'App\Entity\Parts\Storelocation', inversedBy: 'parameters')]
|
||||
#[ORM\ManyToOne(targetEntity: \App\Entity\Parts\Storelocation::class, inversedBy: 'parameters')]
|
||||
#[ORM\JoinColumn(name: 'element_id', nullable: false, onDelete: 'CASCADE')]
|
||||
protected ?AbstractDBElement $element = null;
|
||||
}
|
||||
|
|
|
@ -47,15 +47,15 @@ use Doctrine\ORM\Mapping as ORM;
|
|||
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
||||
|
||||
#[UniqueEntity(fields: ['name', 'group', 'element'])]
|
||||
#[ORM\Entity(repositoryClass: 'App\Repository\ParameterRepository')]
|
||||
#[ORM\Entity(repositoryClass: \App\Repository\ParameterRepository::class)]
|
||||
class SupplierParameter extends AbstractParameter
|
||||
{
|
||||
public const ALLOWED_ELEMENT_CLASS = Supplier::class;
|
||||
final public const ALLOWED_ELEMENT_CLASS = Supplier::class;
|
||||
|
||||
/**
|
||||
* @var Supplier the element this para is associated with
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: 'App\Entity\Parts\Supplier', inversedBy: 'parameters')]
|
||||
#[ORM\ManyToOne(targetEntity: \App\Entity\Parts\Supplier::class, inversedBy: 'parameters')]
|
||||
#[ORM\JoinColumn(name: 'element_id', nullable: false, onDelete: 'CASCADE')]
|
||||
protected ?AbstractDBElement $element = null;
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ use Symfony\Component\Validator\Constraints as Assert;
|
|||
/**
|
||||
* Class AttachmentType.
|
||||
*/
|
||||
#[ORM\Entity(repositoryClass: 'App\Repository\Parts\CategoryRepository')]
|
||||
#[ORM\Entity(repositoryClass: \App\Repository\Parts\CategoryRepository::class)]
|
||||
#[ORM\Table(name: '`categories`')]
|
||||
#[ORM\Index(name: 'category_idx_name', columns: ['name'])]
|
||||
#[ORM\Index(name: 'category_idx_parent_name', columns: ['parent_id', 'name'])]
|
||||
|
@ -112,7 +112,7 @@ class Category extends AbstractPartsContainingDBElement
|
|||
*/
|
||||
#[Assert\Valid]
|
||||
#[Groups(['full'])]
|
||||
#[ORM\OneToMany(targetEntity: 'App\Entity\Attachments\CategoryAttachment', mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
|
||||
#[ORM\OneToMany(targetEntity: \App\Entity\Attachments\CategoryAttachment::class, mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
|
||||
#[ORM\OrderBy(['name' => 'ASC'])]
|
||||
protected Collection $attachments;
|
||||
|
||||
|
@ -120,7 +120,7 @@ class Category extends AbstractPartsContainingDBElement
|
|||
*/
|
||||
#[Assert\Valid]
|
||||
#[Groups(['full'])]
|
||||
#[ORM\OneToMany(targetEntity: 'App\Entity\Parameters\CategoryParameter', mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
|
||||
#[ORM\OneToMany(targetEntity: \App\Entity\Parameters\CategoryParameter::class, mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
|
||||
#[ORM\OrderBy(['group' => 'ASC', 'name' => 'ASC'])]
|
||||
protected Collection $parameters;
|
||||
|
||||
|
@ -129,9 +129,6 @@ class Category extends AbstractPartsContainingDBElement
|
|||
return $this->partname_hint;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Category
|
||||
*/
|
||||
public function setPartnameHint(string $partname_hint): self
|
||||
{
|
||||
$this->partname_hint = $partname_hint;
|
||||
|
@ -144,9 +141,6 @@ class Category extends AbstractPartsContainingDBElement
|
|||
return $this->partname_regex;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Category
|
||||
*/
|
||||
public function setPartnameRegex(string $partname_regex): self
|
||||
{
|
||||
$this->partname_regex = $partname_regex;
|
||||
|
@ -159,9 +153,6 @@ class Category extends AbstractPartsContainingDBElement
|
|||
return $this->disable_footprints;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Category
|
||||
*/
|
||||
public function setDisableFootprints(bool $disable_footprints): self
|
||||
{
|
||||
$this->disable_footprints = $disable_footprints;
|
||||
|
@ -174,9 +165,6 @@ class Category extends AbstractPartsContainingDBElement
|
|||
return $this->disable_manufacturers;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Category
|
||||
*/
|
||||
public function setDisableManufacturers(bool $disable_manufacturers): self
|
||||
{
|
||||
$this->disable_manufacturers = $disable_manufacturers;
|
||||
|
@ -189,9 +177,6 @@ class Category extends AbstractPartsContainingDBElement
|
|||
return $this->disable_autodatasheets;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Category
|
||||
*/
|
||||
public function setDisableAutodatasheets(bool $disable_autodatasheets): self
|
||||
{
|
||||
$this->disable_autodatasheets = $disable_autodatasheets;
|
||||
|
@ -204,9 +189,6 @@ class Category extends AbstractPartsContainingDBElement
|
|||
return $this->disable_properties;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Category
|
||||
*/
|
||||
public function setDisableProperties(bool $disable_properties): self
|
||||
{
|
||||
$this->disable_properties = $disable_properties;
|
||||
|
@ -219,9 +201,6 @@ class Category extends AbstractPartsContainingDBElement
|
|||
return $this->default_description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Category
|
||||
*/
|
||||
public function setDefaultDescription(string $default_description): self
|
||||
{
|
||||
$this->default_description = $default_description;
|
||||
|
@ -234,9 +213,6 @@ class Category extends AbstractPartsContainingDBElement
|
|||
return $this->default_comment;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Category
|
||||
*/
|
||||
public function setDefaultComment(string $default_comment): self
|
||||
{
|
||||
$this->default_comment = $default_comment;
|
||||
|
|
|
@ -32,7 +32,7 @@ use Symfony\Component\Validator\Constraints as Assert;
|
|||
/**
|
||||
* Class Footprint.
|
||||
*/
|
||||
#[ORM\Entity(repositoryClass: 'App\Repository\Parts\FootprintRepository')]
|
||||
#[ORM\Entity(repositoryClass: \App\Repository\Parts\FootprintRepository::class)]
|
||||
#[ORM\Table('`footprints`')]
|
||||
#[ORM\Index(name: 'footprint_idx_name', columns: ['name'])]
|
||||
#[ORM\Index(name: 'footprint_idx_parent_name', columns: ['parent_id', 'name'])]
|
||||
|
@ -40,7 +40,7 @@ class Footprint extends AbstractPartsContainingDBElement
|
|||
{
|
||||
#[ORM\ManyToOne(targetEntity: 'Footprint', inversedBy: 'children')]
|
||||
#[ORM\JoinColumn(name: 'parent_id')]
|
||||
protected ?\App\Entity\Base\AbstractStructuralDBElement $parent;
|
||||
protected ?\App\Entity\Base\AbstractStructuralDBElement $parent = null;
|
||||
|
||||
/**
|
||||
* @var Collection
|
||||
|
@ -53,21 +53,21 @@ class Footprint extends AbstractPartsContainingDBElement
|
|||
* @var Collection<int, FootprintAttachment>
|
||||
*/
|
||||
#[Assert\Valid]
|
||||
#[ORM\OneToMany(targetEntity: 'App\Entity\Attachments\FootprintAttachment', mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
|
||||
#[ORM\OneToMany(targetEntity: \App\Entity\Attachments\FootprintAttachment::class, mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
|
||||
#[ORM\OrderBy(['name' => 'ASC'])]
|
||||
protected Collection $attachments;
|
||||
|
||||
/**
|
||||
* @var FootprintAttachment|null
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: 'App\Entity\Attachments\FootprintAttachment')]
|
||||
#[ORM\ManyToOne(targetEntity: \App\Entity\Attachments\FootprintAttachment::class)]
|
||||
#[ORM\JoinColumn(name: 'id_footprint_3d')]
|
||||
protected ?FootprintAttachment $footprint_3d = null;
|
||||
|
||||
/** @var Collection<int, FootprintParameter>
|
||||
*/
|
||||
#[Assert\Valid]
|
||||
#[ORM\OneToMany(targetEntity: 'App\Entity\Parameters\FootprintParameter', mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
|
||||
#[ORM\OneToMany(targetEntity: \App\Entity\Parameters\FootprintParameter::class, mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
|
||||
#[ORM\OrderBy(['group' => 'ASC', 'name' => 'ASC'])]
|
||||
protected Collection $parameters;
|
||||
|
||||
|
@ -88,13 +88,10 @@ class Footprint extends AbstractPartsContainingDBElement
|
|||
* Setters
|
||||
*
|
||||
*********************************************************************************/
|
||||
|
||||
/**
|
||||
* Sets the 3D Model associated with this footprint.
|
||||
*
|
||||
* @param FootprintAttachment|null $new_attachment The new 3D Model
|
||||
*
|
||||
* @return Footprint
|
||||
*/
|
||||
public function setFootprint3d(?FootprintAttachment $new_attachment): self
|
||||
{
|
||||
|
|
|
@ -32,7 +32,7 @@ use Symfony\Component\Validator\Constraints as Assert;
|
|||
/**
|
||||
* Class Manufacturer.
|
||||
*/
|
||||
#[ORM\Entity(repositoryClass: 'App\Repository\Parts\ManufacturerRepository')]
|
||||
#[ORM\Entity(repositoryClass: \App\Repository\Parts\ManufacturerRepository::class)]
|
||||
#[ORM\Table('`manufacturers`')]
|
||||
#[ORM\Index(name: 'manufacturer_name', columns: ['name'])]
|
||||
#[ORM\Index(name: 'manufacturer_idx_parent_name', columns: ['parent_id', 'name'])]
|
||||
|
@ -40,7 +40,7 @@ class Manufacturer extends AbstractCompany
|
|||
{
|
||||
#[ORM\ManyToOne(targetEntity: 'Manufacturer', inversedBy: 'children')]
|
||||
#[ORM\JoinColumn(name: 'parent_id')]
|
||||
protected ?\App\Entity\Base\AbstractStructuralDBElement $parent;
|
||||
protected ?\App\Entity\Base\AbstractStructuralDBElement $parent = null;
|
||||
|
||||
/**
|
||||
* @var Collection
|
||||
|
@ -53,14 +53,14 @@ class Manufacturer extends AbstractCompany
|
|||
* @var Collection<int, ManufacturerAttachment>
|
||||
*/
|
||||
#[Assert\Valid]
|
||||
#[ORM\OneToMany(targetEntity: 'App\Entity\Attachments\ManufacturerAttachment', mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
|
||||
#[ORM\OneToMany(targetEntity: \App\Entity\Attachments\ManufacturerAttachment::class, mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
|
||||
#[ORM\OrderBy(['name' => 'ASC'])]
|
||||
protected Collection $attachments;
|
||||
|
||||
/** @var Collection<int, ManufacturerParameter>
|
||||
*/
|
||||
#[Assert\Valid]
|
||||
#[ORM\OneToMany(targetEntity: 'App\Entity\Parameters\ManufacturerParameter', mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
|
||||
#[ORM\OneToMany(targetEntity: \App\Entity\Parameters\ManufacturerParameter::class, mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
|
||||
#[ORM\OrderBy(['group' => 'ASC', 'name' => 'ASC'])]
|
||||
protected Collection $parameters;
|
||||
public function __construct()
|
||||
|
|
|
@ -36,7 +36,7 @@ use Symfony\Component\Validator\Constraints as Assert;
|
|||
* This could be something like N, grams, meters, etc...
|
||||
*/
|
||||
#[UniqueEntity('unit')]
|
||||
#[ORM\Entity(repositoryClass: 'App\Repository\Parts\MeasurementUnitRepository')]
|
||||
#[ORM\Entity(repositoryClass: \App\Repository\Parts\MeasurementUnitRepository::class)]
|
||||
#[ORM\Table(name: '`measurement_units`')]
|
||||
#[ORM\Index(name: 'unit_idx_name', columns: ['name'])]
|
||||
#[ORM\Index(name: 'unit_idx_parent_name', columns: ['parent_id', 'name'])]
|
||||
|
@ -77,20 +77,20 @@ class MeasurementUnit extends AbstractPartsContainingDBElement
|
|||
|
||||
#[ORM\ManyToOne(targetEntity: 'MeasurementUnit', inversedBy: 'children')]
|
||||
#[ORM\JoinColumn(name: 'parent_id')]
|
||||
protected ?\App\Entity\Base\AbstractStructuralDBElement $parent;
|
||||
protected ?\App\Entity\Base\AbstractStructuralDBElement $parent = null;
|
||||
|
||||
/**
|
||||
* @var Collection<int, MeasurementUnitAttachment>
|
||||
*/
|
||||
#[Assert\Valid]
|
||||
#[ORM\OneToMany(targetEntity: 'App\Entity\Attachments\MeasurementUnitAttachment', mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
|
||||
#[ORM\OneToMany(targetEntity: \App\Entity\Attachments\MeasurementUnitAttachment::class, mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
|
||||
#[ORM\OrderBy(['name' => 'ASC'])]
|
||||
protected Collection $attachments;
|
||||
|
||||
/** @var Collection<int, MeasurementUnitParameter>
|
||||
*/
|
||||
#[Assert\Valid]
|
||||
#[ORM\OneToMany(targetEntity: 'App\Entity\Parameters\MeasurementUnitParameter', mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
|
||||
#[ORM\OneToMany(targetEntity: \App\Entity\Parameters\MeasurementUnitParameter::class, mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
|
||||
#[ORM\OrderBy(['group' => 'ASC', 'name' => 'ASC'])]
|
||||
protected Collection $parameters;
|
||||
|
||||
|
@ -102,11 +102,6 @@ class MeasurementUnit extends AbstractPartsContainingDBElement
|
|||
return $this->unit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null $unit
|
||||
*
|
||||
* @return MeasurementUnit
|
||||
*/
|
||||
public function setUnit(?string $unit): self
|
||||
{
|
||||
$this->unit = $unit;
|
||||
|
@ -119,9 +114,6 @@ class MeasurementUnit extends AbstractPartsContainingDBElement
|
|||
return $this->is_integer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MeasurementUnit
|
||||
*/
|
||||
public function setIsInteger(bool $isInteger): self
|
||||
{
|
||||
$this->is_integer = $isInteger;
|
||||
|
@ -134,9 +126,6 @@ class MeasurementUnit extends AbstractPartsContainingDBElement
|
|||
return $this->use_si_prefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MeasurementUnit
|
||||
*/
|
||||
public function setUseSIPrefix(bool $usesSIPrefixes): self
|
||||
{
|
||||
$this->use_si_prefix = $usesSIPrefixes;
|
||||
|
|
|
@ -49,7 +49,7 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
|||
* Otherwise, this class would be too big, to be maintained.
|
||||
*/
|
||||
#[UniqueEntity(fields: ['ipn'], message: 'part.ipn.must_be_unique')]
|
||||
#[ORM\Entity(repositoryClass: 'App\Repository\PartRepository')]
|
||||
#[ORM\Entity(repositoryClass: \App\Repository\PartRepository::class)]
|
||||
#[ORM\Table('`parts`')]
|
||||
#[ORM\Index(name: 'parts_idx_datet_name_last_id_needs', columns: ['datetime_added', 'name', 'last_modified', 'id', 'needs_review'])]
|
||||
#[ORM\Index(name: 'parts_idx_name', columns: ['name'])]
|
||||
|
@ -69,7 +69,7 @@ class Part extends AttachmentContainingDBElement
|
|||
*/
|
||||
#[Assert\Valid]
|
||||
#[Groups(['full'])]
|
||||
#[ORM\OneToMany(targetEntity: 'App\Entity\Parameters\PartParameter', mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
|
||||
#[ORM\OneToMany(targetEntity: \App\Entity\Parameters\PartParameter::class, mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
|
||||
#[ORM\OrderBy(['group' => 'ASC', 'name' => 'ASC'])]
|
||||
protected Collection $parameters;
|
||||
|
||||
|
@ -89,7 +89,7 @@ class Part extends AttachmentContainingDBElement
|
|||
*/
|
||||
#[Assert\Valid]
|
||||
#[Groups(['full'])]
|
||||
#[ORM\OneToMany(targetEntity: 'App\Entity\Attachments\PartAttachment', mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
|
||||
#[ORM\OneToMany(targetEntity: \App\Entity\Attachments\PartAttachment::class, mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
|
||||
#[ORM\OrderBy(['name' => 'ASC'])]
|
||||
protected Collection $attachments;
|
||||
|
||||
|
@ -97,7 +97,7 @@ class Part extends AttachmentContainingDBElement
|
|||
* @var Attachment|null
|
||||
*/
|
||||
#[Assert\Expression('value == null or value.isPicture()', message: 'part.master_attachment.must_be_picture')]
|
||||
#[ORM\ManyToOne(targetEntity: 'App\Entity\Attachments\Attachment')]
|
||||
#[ORM\ManyToOne(targetEntity: \App\Entity\Attachments\Attachment::class)]
|
||||
#[ORM\JoinColumn(name: 'id_preview_attachment', onDelete: 'SET NULL')]
|
||||
protected ?Attachment $master_picture_attachment = null;
|
||||
|
||||
|
@ -142,15 +142,13 @@ class Part extends AttachmentContainingDBElement
|
|||
public function validate(ExecutionContextInterface $context, $payload)
|
||||
{
|
||||
//Ensure that the part name fullfills the regex of the category
|
||||
if ($this->category) {
|
||||
if ($this->category instanceof \App\Entity\Parts\Category) {
|
||||
$regex = $this->category->getPartnameRegex();
|
||||
if (!empty($regex)) {
|
||||
if (!preg_match($regex, $this->name)) {
|
||||
$context->buildViolation('part.name.must_match_category_regex')
|
||||
->atPath('name')
|
||||
->setParameter('%regex%', $regex)
|
||||
->addViolation();
|
||||
}
|
||||
if (!empty($regex) && !preg_match($regex, $this->name)) {
|
||||
$context->buildViolation('part.name.must_match_category_regex')
|
||||
->atPath('name')
|
||||
->setParameter('%regex%', $regex)
|
||||
->addViolation();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -115,7 +115,7 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface, Named
|
|||
/**
|
||||
* @var User|null The owner of this part lot
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: 'App\Entity\UserSystem\User')]
|
||||
#[ORM\ManyToOne(targetEntity: \App\Entity\UserSystem\User::class)]
|
||||
#[ORM\JoinColumn(name: 'id_owner', onDelete: 'SET NULL')]
|
||||
protected ?User $owner = null;
|
||||
|
||||
|
@ -137,7 +137,7 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface, Named
|
|||
*/
|
||||
public function isExpired(): ?bool
|
||||
{
|
||||
if (null === $this->expiration_date) {
|
||||
if (!$this->expiration_date instanceof \DateTimeInterface) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -155,8 +155,6 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface, Named
|
|||
|
||||
/**
|
||||
* Sets the description of the part lot.
|
||||
*
|
||||
* @return PartLot
|
||||
*/
|
||||
public function setDescription(string $description): self
|
||||
{
|
||||
|
@ -175,8 +173,6 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface, Named
|
|||
|
||||
/**
|
||||
* Sets the comment for this part lot.
|
||||
*
|
||||
* @return PartLot
|
||||
*/
|
||||
public function setComment(string $comment): self
|
||||
{
|
||||
|
@ -196,9 +192,7 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface, Named
|
|||
/**
|
||||
* Sets the expiration date for the part lot. Set to null, if the part lot does not expire.
|
||||
*
|
||||
* @param \DateTimeInterface|null $expiration_date
|
||||
*
|
||||
* @return PartLot
|
||||
*/
|
||||
public function setExpirationDate(?\DateTimeInterface $expiration_date): self
|
||||
{
|
||||
|
@ -219,8 +213,6 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface, Named
|
|||
|
||||
/**
|
||||
* Sets the storage location, where this part lot is stored.
|
||||
*
|
||||
* @return PartLot
|
||||
*/
|
||||
public function setStorageLocation(?Storelocation $storage_location): self
|
||||
{
|
||||
|
@ -239,8 +231,6 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface, Named
|
|||
|
||||
/**
|
||||
* Sets the part that is stored in this part lot.
|
||||
*
|
||||
* @return PartLot
|
||||
*/
|
||||
public function setPart(Part $part): self
|
||||
{
|
||||
|
@ -259,8 +249,6 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface, Named
|
|||
|
||||
/**
|
||||
* Set the unknown instock status of this part lot.
|
||||
*
|
||||
* @return PartLot
|
||||
*/
|
||||
public function setInstockUnknown(bool $instock_unknown): self
|
||||
{
|
||||
|
@ -302,9 +290,6 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface, Named
|
|||
return $this->needs_refill;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PartLot
|
||||
*/
|
||||
public function setNeedsRefill(bool $needs_refill): self
|
||||
{
|
||||
$this->needs_refill = $needs_refill;
|
||||
|
@ -314,7 +299,6 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface, Named
|
|||
|
||||
/**
|
||||
* Returns the owner of this part lot.
|
||||
* @return User|null
|
||||
*/
|
||||
public function getOwner(): ?User
|
||||
{
|
||||
|
@ -323,8 +307,6 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface, Named
|
|||
|
||||
/**
|
||||
* Sets the owner of this part lot.
|
||||
* @param User|null $owner
|
||||
* @return PartLot
|
||||
*/
|
||||
public function setOwner(?User $owner): PartLot
|
||||
{
|
||||
|
@ -349,14 +331,12 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface, Named
|
|||
|
||||
//When the storage location sets the owner must match, the part lot owner must match the storage location owner
|
||||
if ($this->getStorageLocation() && $this->getStorageLocation()->isPartOwnerMustMatch()
|
||||
&& $this->getStorageLocation()->getOwner() && $this->getOwner()) {
|
||||
if ($this->getOwner() !== $this->getStorageLocation()->getOwner()
|
||||
&& $this->owner->getID() !== $this->getStorageLocation()->getOwner()->getID()) {
|
||||
$context->buildViolation('validator.part_lot.owner_must_match_storage_location_owner')
|
||||
->setParameter('%owner_name%', $this->getStorageLocation()->getOwner()->getFullName(true))
|
||||
->atPath('owner')
|
||||
->addViolation();
|
||||
}
|
||||
&& $this->getStorageLocation()->getOwner() && $this->getOwner() && ($this->getOwner() !== $this->getStorageLocation()->getOwner()
|
||||
&& $this->owner->getID() !== $this->getStorageLocation()->getOwner()->getID())) {
|
||||
$context->buildViolation('validator.part_lot.owner_must_match_storage_location_owner')
|
||||
->setParameter('%owner_name%', $this->getStorageLocation()->getOwner()->getFullName(true))
|
||||
->atPath('owner')
|
||||
->addViolation();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -142,7 +142,6 @@ trait AdvancedPropertyTrait
|
|||
/**
|
||||
* Sets the internal part number of the part
|
||||
* @param string $ipn The new IPN of the part
|
||||
* @return Part
|
||||
*/
|
||||
public function setIpn(?string $ipn): Part
|
||||
{
|
||||
|
|
|
@ -153,7 +153,6 @@ trait InstockTrait
|
|||
|
||||
/**
|
||||
* Returns true, if the total instock amount of this part is less than the minimum amount.
|
||||
* @return bool
|
||||
*/
|
||||
public function isNotEnoughInstock(): bool
|
||||
{
|
||||
|
@ -204,7 +203,6 @@ trait InstockTrait
|
|||
|
||||
/**
|
||||
* Returns the summed amount of all part lots that are expired. If no part lots are expired 0 is returned.
|
||||
* @return float
|
||||
*/
|
||||
public function getExpiredAmountSum(): float
|
||||
{
|
||||
|
|
|
@ -39,7 +39,7 @@ trait OrderTrait
|
|||
*/
|
||||
#[Assert\Valid]
|
||||
#[Groups(['extended', 'full', 'import'])]
|
||||
#[ORM\OneToMany(targetEntity: 'App\Entity\PriceInformations\Orderdetail', mappedBy: 'part', cascade: ['persist', 'remove'], orphanRemoval: true)]
|
||||
#[ORM\OneToMany(targetEntity: \App\Entity\PriceInformations\Orderdetail::class, mappedBy: 'part', cascade: ['persist', 'remove'], orphanRemoval: true)]
|
||||
#[ORM\OrderBy(['supplierpartnr' => 'ASC'])]
|
||||
protected \Doctrine\Common\Collections\Collection $orderdetails;
|
||||
|
||||
|
@ -58,7 +58,7 @@ trait OrderTrait
|
|||
/**
|
||||
* @var Orderdetail|null
|
||||
*/
|
||||
#[ORM\OneToOne(targetEntity: 'App\Entity\PriceInformations\Orderdetail')]
|
||||
#[ORM\OneToOne(targetEntity: \App\Entity\PriceInformations\Orderdetail::class)]
|
||||
#[ORM\JoinColumn(name: 'order_orderdetails_id')]
|
||||
protected ?Orderdetail $order_orderdetail = null;
|
||||
|
||||
|
@ -105,9 +105,7 @@ trait OrderTrait
|
|||
{
|
||||
//If needed hide the obsolete entries
|
||||
if ($hide_obsolete) {
|
||||
return $this->orderdetails->filter(function (Orderdetail $orderdetail) {
|
||||
return ! $orderdetail->getObsolete();
|
||||
});
|
||||
return $this->orderdetails->filter(fn(Orderdetail $orderdetail) => ! $orderdetail->getObsolete());
|
||||
}
|
||||
|
||||
return $this->orderdetails;
|
||||
|
|
|
@ -13,13 +13,13 @@ trait ProjectTrait
|
|||
/**
|
||||
* @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)]
|
||||
#[ORM\OneToMany(targetEntity: \App\Entity\ProjectSystem\ProjectBOMEntry::class, mappedBy: 'part', cascade: ['remove'], orphanRemoval: true)]
|
||||
protected \Doctrine\Common\Collections\Collection $project_bom_entries;
|
||||
|
||||
/**
|
||||
* @var Project|null If a project is set here, then this part is special and represents the builds of a project.
|
||||
*/
|
||||
#[ORM\OneToOne(targetEntity: 'App\Entity\ProjectSystem\Project', inversedBy: 'build_part')]
|
||||
#[ORM\OneToOne(targetEntity: \App\Entity\ProjectSystem\Project::class, inversedBy: 'build_part')]
|
||||
#[ORM\JoinColumn]
|
||||
protected ?Project $built_project = null;
|
||||
|
||||
|
@ -43,7 +43,6 @@ trait ProjectTrait
|
|||
|
||||
/**
|
||||
* Returns the project that this part represents the builds of, or null if it doesn't
|
||||
* @return Project|null
|
||||
*/
|
||||
public function getBuiltProject(): ?Project
|
||||
{
|
||||
|
|
|
@ -35,7 +35,7 @@ use Symfony\Component\Validator\Constraints as Assert;
|
|||
/**
|
||||
* Class Store location.
|
||||
*/
|
||||
#[ORM\Entity(repositoryClass: 'App\Repository\Parts\StorelocationRepository')]
|
||||
#[ORM\Entity(repositoryClass: \App\Repository\Parts\StorelocationRepository::class)]
|
||||
#[ORM\Table('`storelocations`')]
|
||||
#[ORM\Index(name: 'location_idx_name', columns: ['name'])]
|
||||
#[ORM\Index(name: 'location_idx_parent_name', columns: ['parent_id', 'name'])]
|
||||
|
@ -50,7 +50,7 @@ class Storelocation extends AbstractPartsContainingDBElement
|
|||
|
||||
#[ORM\ManyToOne(targetEntity: 'Storelocation', inversedBy: 'children')]
|
||||
#[ORM\JoinColumn(name: 'parent_id')]
|
||||
protected ?AbstractStructuralDBElement $parent;
|
||||
protected ?AbstractStructuralDBElement $parent = null;
|
||||
|
||||
/**
|
||||
* @var MeasurementUnit|null The measurement unit, which parts can be stored in here
|
||||
|
@ -62,7 +62,7 @@ class Storelocation extends AbstractPartsContainingDBElement
|
|||
/** @var Collection<int, StorelocationParameter>
|
||||
*/
|
||||
#[Assert\Valid]
|
||||
#[ORM\OneToMany(targetEntity: 'App\Entity\Parameters\StorelocationParameter', mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
|
||||
#[ORM\OneToMany(targetEntity: \App\Entity\Parameters\StorelocationParameter::class, mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
|
||||
#[ORM\OrderBy(['group' => 'ASC', 'name' => 'ASC'])]
|
||||
protected Collection $parameters;
|
||||
|
||||
|
@ -91,7 +91,7 @@ class Storelocation extends AbstractPartsContainingDBElement
|
|||
* @var User|null The owner of this storage location
|
||||
*/
|
||||
#[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\ManyToOne(targetEntity: \App\Entity\UserSystem\User::class)]
|
||||
#[ORM\JoinColumn(name: 'id_owner', onDelete: 'SET NULL')]
|
||||
protected ?User $owner = null;
|
||||
|
||||
|
@ -105,7 +105,7 @@ class Storelocation extends AbstractPartsContainingDBElement
|
|||
* @var Collection<int, StorelocationAttachment>
|
||||
*/
|
||||
#[Assert\Valid]
|
||||
#[ORM\OneToMany(targetEntity: 'App\Entity\Attachments\StorelocationAttachment', mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
|
||||
#[ORM\OneToMany(targetEntity: \App\Entity\Attachments\StorelocationAttachment::class, mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
|
||||
protected Collection $attachments;
|
||||
|
||||
/********************************************************************************
|
||||
|
@ -135,9 +135,6 @@ class Storelocation extends AbstractPartsContainingDBElement
|
|||
return $this->only_single_part;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Storelocation
|
||||
*/
|
||||
public function setOnlySinglePart(bool $only_single_part): self
|
||||
{
|
||||
$this->only_single_part = $only_single_part;
|
||||
|
@ -153,9 +150,6 @@ class Storelocation extends AbstractPartsContainingDBElement
|
|||
return $this->limit_to_existing_parts;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Storelocation
|
||||
*/
|
||||
public function setLimitToExistingParts(bool $limit_to_existing_parts): self
|
||||
{
|
||||
$this->limit_to_existing_parts = $limit_to_existing_parts;
|
||||
|
@ -168,9 +162,6 @@ class Storelocation extends AbstractPartsContainingDBElement
|
|||
return $this->storage_type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Storelocation
|
||||
*/
|
||||
public function setStorageType(?MeasurementUnit $storage_type): self
|
||||
{
|
||||
$this->storage_type = $storage_type;
|
||||
|
@ -180,7 +171,6 @@ class Storelocation extends AbstractPartsContainingDBElement
|
|||
|
||||
/**
|
||||
* Returns the owner of this storage location
|
||||
* @return User|null
|
||||
*/
|
||||
public function getOwner(): ?User
|
||||
{
|
||||
|
@ -189,8 +179,6 @@ class Storelocation extends AbstractPartsContainingDBElement
|
|||
|
||||
/**
|
||||
* Sets the owner of this storage location
|
||||
* @param User|null $owner
|
||||
* @return Storelocation
|
||||
*/
|
||||
public function setOwner(?User $owner): Storelocation
|
||||
{
|
||||
|
@ -200,7 +188,6 @@ class Storelocation extends AbstractPartsContainingDBElement
|
|||
|
||||
/**
|
||||
* 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.
|
||||
* @return bool
|
||||
*/
|
||||
public function isPartOwnerMustMatch(): bool
|
||||
{
|
||||
|
@ -209,8 +196,6 @@ class Storelocation extends AbstractPartsContainingDBElement
|
|||
|
||||
/**
|
||||
* 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.
|
||||
* @param bool $part_owner_must_match
|
||||
* @return Storelocation
|
||||
*/
|
||||
public function setPartOwnerMustMatch(bool $part_owner_must_match): Storelocation
|
||||
{
|
||||
|
@ -226,7 +211,6 @@ class Storelocation extends AbstractPartsContainingDBElement
|
|||
* Setters
|
||||
*
|
||||
*********************************************************************************/
|
||||
|
||||
/**
|
||||
* Change the "is full" attribute of this store location.
|
||||
*
|
||||
|
@ -235,8 +219,6 @@ class Storelocation extends AbstractPartsContainingDBElement
|
|||
*
|
||||
* @param bool $new_is_full * true means that the storelocation is full
|
||||
* * false means that the storelocation isn't full
|
||||
*
|
||||
* @return Storelocation
|
||||
*/
|
||||
public function setIsFull(bool $new_is_full): self
|
||||
{
|
||||
|
|
|
@ -38,7 +38,7 @@ use Symfony\Component\Validator\Constraints as Assert;
|
|||
/**
|
||||
* Class Supplier.
|
||||
*/
|
||||
#[ORM\Entity(repositoryClass: 'App\Repository\Parts\SupplierRepository')]
|
||||
#[ORM\Entity(repositoryClass: \App\Repository\Parts\SupplierRepository::class)]
|
||||
#[ORM\Table('`suppliers`')]
|
||||
#[ORM\Index(name: 'supplier_idx_name', columns: ['name'])]
|
||||
#[ORM\Index(name: 'supplier_idx_parent_name', columns: ['parent_id', 'name'])]
|
||||
|
@ -53,12 +53,12 @@ class Supplier extends AbstractCompany
|
|||
|
||||
#[ORM\ManyToOne(targetEntity: 'Supplier', inversedBy: 'children')]
|
||||
#[ORM\JoinColumn(name: 'parent_id')]
|
||||
protected ?AbstractStructuralDBElement $parent;
|
||||
protected ?AbstractStructuralDBElement $parent = null;
|
||||
|
||||
/**
|
||||
* @var \Doctrine\Common\Collections\Collection<int, \App\Entity\PriceInformations\Orderdetail>|\App\Entity\PriceInformations\Orderdetail[]
|
||||
*/
|
||||
#[ORM\OneToMany(targetEntity: 'App\Entity\PriceInformations\Orderdetail', mappedBy: 'supplier')]
|
||||
#[ORM\OneToMany(targetEntity: \App\Entity\PriceInformations\Orderdetail::class, mappedBy: 'supplier')]
|
||||
protected Collection $orderdetails;
|
||||
|
||||
/**
|
||||
|
@ -66,7 +66,7 @@ class Supplier extends AbstractCompany
|
|||
* Set to null, to use global base currency.
|
||||
* @Selectable()
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: 'App\Entity\PriceInformations\Currency')]
|
||||
#[ORM\ManyToOne(targetEntity: \App\Entity\PriceInformations\Currency::class)]
|
||||
#[ORM\JoinColumn(name: 'default_currency_id')]
|
||||
protected ?Currency $default_currency = null;
|
||||
|
||||
|
@ -82,14 +82,14 @@ class Supplier extends AbstractCompany
|
|||
* @var Collection<int, SupplierAttachment>
|
||||
*/
|
||||
#[Assert\Valid]
|
||||
#[ORM\OneToMany(targetEntity: 'App\Entity\Attachments\SupplierAttachment', mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
|
||||
#[ORM\OneToMany(targetEntity: \App\Entity\Attachments\SupplierAttachment::class, mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
|
||||
#[ORM\OrderBy(['name' => 'ASC'])]
|
||||
protected Collection $attachments;
|
||||
|
||||
/** @var Collection<int, SupplierParameter>
|
||||
*/
|
||||
#[Assert\Valid]
|
||||
#[ORM\OneToMany(targetEntity: 'App\Entity\Parameters\SupplierParameter', mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
|
||||
#[ORM\OneToMany(targetEntity: \App\Entity\Parameters\SupplierParameter::class, mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
|
||||
#[ORM\OrderBy(['group' => 'ASC', 'name' => 'ASC'])]
|
||||
protected Collection $parameters;
|
||||
|
||||
|
@ -103,8 +103,6 @@ class Supplier extends AbstractCompany
|
|||
|
||||
/**
|
||||
* Sets the default currency.
|
||||
*
|
||||
* @return Supplier
|
||||
*/
|
||||
public function setDefaultCurrency(?Currency $default_currency): self
|
||||
{
|
||||
|
@ -127,12 +125,10 @@ class Supplier extends AbstractCompany
|
|||
* Sets the shipping costs for an order with this supplier.
|
||||
*
|
||||
* @param BigDecimal|null $shipping_costs a BigDecimal with the shipping costs
|
||||
*
|
||||
* @return Supplier
|
||||
*/
|
||||
public function setShippingCosts(?BigDecimal $shipping_costs): self
|
||||
{
|
||||
if (null === $shipping_costs) {
|
||||
if (!$shipping_costs instanceof \Brick\Math\BigDecimal) {
|
||||
$this->shipping_costs = null;
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ use Symfony\Component\Validator\Constraints as Assert;
|
|||
#[ORM\Index(name: 'currency_idx_parent_name', columns: ['parent_id', 'name'])]
|
||||
class Currency extends AbstractStructuralDBElement
|
||||
{
|
||||
public const PRICE_SCALE = 5;
|
||||
final public const PRICE_SCALE = 5;
|
||||
|
||||
/**
|
||||
* @var BigDecimal|null The exchange rate between this currency and the base currency
|
||||
|
@ -69,26 +69,26 @@ class Currency extends AbstractStructuralDBElement
|
|||
|
||||
#[ORM\ManyToOne(targetEntity: 'Currency', inversedBy: 'children')]
|
||||
#[ORM\JoinColumn(name: 'parent_id')]
|
||||
protected ?AbstractStructuralDBElement $parent;
|
||||
protected ?AbstractStructuralDBElement $parent = null;
|
||||
|
||||
/**
|
||||
* @var Collection<int, CurrencyAttachment>
|
||||
*/
|
||||
#[Assert\Valid]
|
||||
#[ORM\OneToMany(targetEntity: 'App\Entity\Attachments\CurrencyAttachment', mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
|
||||
#[ORM\OneToMany(targetEntity: \App\Entity\Attachments\CurrencyAttachment::class, mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
|
||||
#[ORM\OrderBy(['name' => 'ASC'])]
|
||||
protected Collection $attachments;
|
||||
|
||||
/** @var Collection<int, CurrencyParameter>
|
||||
*/
|
||||
#[Assert\Valid]
|
||||
#[ORM\OneToMany(targetEntity: 'App\Entity\Parameters\CurrencyParameter', mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
|
||||
#[ORM\OneToMany(targetEntity: \App\Entity\Parameters\CurrencyParameter::class, mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
|
||||
#[ORM\OrderBy(['group' => 'ASC', 'name' => 'ASC'])]
|
||||
protected Collection $parameters;
|
||||
|
||||
/** @var Collection<int, Pricedetail>
|
||||
*/
|
||||
#[ORM\OneToMany(targetEntity: 'App\Entity\PriceInformations\Pricedetail', mappedBy: 'currency')]
|
||||
#[ORM\OneToMany(targetEntity: \App\Entity\PriceInformations\Pricedetail::class, mappedBy: 'currency')]
|
||||
protected Collection $pricedetails;
|
||||
|
||||
public function __construct()
|
||||
|
@ -115,11 +115,6 @@ class Currency extends AbstractStructuralDBElement
|
|||
return $this->iso_code;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null $iso_code
|
||||
*
|
||||
* @return Currency
|
||||
*/
|
||||
public function setIsoCode(?string $iso_code): self
|
||||
{
|
||||
$this->iso_code = $iso_code;
|
||||
|
@ -134,7 +129,7 @@ class Currency extends AbstractStructuralDBElement
|
|||
{
|
||||
$tmp = $this->getExchangeRate();
|
||||
|
||||
if (null === $tmp || $tmp->isZero()) {
|
||||
if (!$tmp instanceof \Brick\Math\BigDecimal || $tmp->isZero()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -155,12 +150,10 @@ class Currency extends AbstractStructuralDBElement
|
|||
*
|
||||
* @param BigDecimal|null $exchange_rate The new exchange rate of the currency.
|
||||
* Set to null, if the exchange rate is unknown.
|
||||
*
|
||||
* @return Currency
|
||||
*/
|
||||
public function setExchangeRate(?BigDecimal $exchange_rate): self
|
||||
{
|
||||
if (null === $exchange_rate) {
|
||||
if (!$exchange_rate instanceof \Brick\Math\BigDecimal) {
|
||||
$this->exchange_rate = null;
|
||||
}
|
||||
$tmp = $exchange_rate->toScale(self::PRICE_SCALE, RoundingMode::HALF_UP);
|
||||
|
|
|
@ -81,7 +81,7 @@ class Orderdetail extends AbstractDBElement implements TimeStampableInterface, N
|
|||
* @var Part|null
|
||||
*/
|
||||
#[Assert\NotNull]
|
||||
#[ORM\ManyToOne(targetEntity: 'App\Entity\Parts\Part', inversedBy: 'orderdetails')]
|
||||
#[ORM\ManyToOne(targetEntity: \App\Entity\Parts\Part::class, inversedBy: 'orderdetails')]
|
||||
#[ORM\JoinColumn(name: 'part_id', nullable: false, onDelete: 'CASCADE')]
|
||||
protected ?Part $part = null;
|
||||
|
||||
|
@ -90,7 +90,7 @@ class Orderdetail extends AbstractDBElement implements TimeStampableInterface, N
|
|||
*/
|
||||
#[Assert\NotNull(message: 'validator.orderdetail.supplier_must_not_be_null')]
|
||||
#[Groups(['extended', 'full', 'import'])]
|
||||
#[ORM\ManyToOne(targetEntity: 'App\Entity\Parts\Supplier', inversedBy: 'orderdetails')]
|
||||
#[ORM\ManyToOne(targetEntity: \App\Entity\Parts\Supplier::class, inversedBy: 'orderdetails')]
|
||||
#[ORM\JoinColumn(name: 'id_supplier')]
|
||||
protected ?Supplier $supplier = null;
|
||||
|
||||
|
@ -121,7 +121,7 @@ class Orderdetail extends AbstractDBElement implements TimeStampableInterface, N
|
|||
public function updateTimestamps(): void
|
||||
{
|
||||
$this->lastModified = new DateTime('now');
|
||||
if (null === $this->addedDate) {
|
||||
if (!$this->addedDate instanceof \DateTimeInterface) {
|
||||
$this->addedDate = new DateTime('now');
|
||||
}
|
||||
|
||||
|
@ -194,7 +194,7 @@ class Orderdetail extends AbstractDBElement implements TimeStampableInterface, N
|
|||
return $this->supplier_product_url;
|
||||
}
|
||||
|
||||
if (null === $this->getSupplier()) {
|
||||
if (!$this->getSupplier() instanceof \App\Entity\Parts\Supplier) {
|
||||
return '';
|
||||
}
|
||||
|
||||
|
@ -216,8 +216,6 @@ class Orderdetail extends AbstractDBElement implements TimeStampableInterface, N
|
|||
* Adds a price detail to this orderdetail.
|
||||
*
|
||||
* @param Pricedetail $pricedetail The pricedetail to add
|
||||
*
|
||||
* @return Orderdetail
|
||||
*/
|
||||
public function addPricedetail(Pricedetail $pricedetail): self
|
||||
{
|
||||
|
@ -229,8 +227,6 @@ class Orderdetail extends AbstractDBElement implements TimeStampableInterface, N
|
|||
|
||||
/**
|
||||
* Removes a price detail from this orderdetail.
|
||||
*
|
||||
* @return Orderdetail
|
||||
*/
|
||||
public function removePricedetail(Pricedetail $pricedetail): self
|
||||
{
|
||||
|
@ -273,11 +269,8 @@ class Orderdetail extends AbstractDBElement implements TimeStampableInterface, N
|
|||
* Setters
|
||||
*
|
||||
*********************************************************************************/
|
||||
|
||||
/**
|
||||
* Sets a new part with which this orderdetail is associated.
|
||||
*
|
||||
* @return Orderdetail
|
||||
*/
|
||||
public function setPart(Part $part): self
|
||||
{
|
||||
|
@ -288,8 +281,6 @@ class Orderdetail extends AbstractDBElement implements TimeStampableInterface, N
|
|||
|
||||
/**
|
||||
* Sets the new supplier associated with this orderdetail.
|
||||
*
|
||||
* @return Orderdetail
|
||||
*/
|
||||
public function setSupplier(Supplier $new_supplier): self
|
||||
{
|
||||
|
@ -302,9 +293,6 @@ class Orderdetail extends AbstractDBElement implements TimeStampableInterface, N
|
|||
* Set the supplier part-nr.
|
||||
*
|
||||
* @param string $new_supplierpartnr the new supplier-part-nr
|
||||
*
|
||||
* @return Orderdetail
|
||||
* @return Orderdetail
|
||||
*/
|
||||
public function setSupplierpartnr(string $new_supplierpartnr): self
|
||||
{
|
||||
|
@ -317,9 +305,6 @@ class Orderdetail extends AbstractDBElement implements TimeStampableInterface, N
|
|||
* Set if the part is obsolete at the supplier of that orderdetails.
|
||||
*
|
||||
* @param bool $new_obsolete true means that this part is obsolete
|
||||
*
|
||||
* @return Orderdetail
|
||||
* @return Orderdetail
|
||||
*/
|
||||
public function setObsolete(bool $new_obsolete): self
|
||||
{
|
||||
|
@ -333,8 +318,6 @@ class Orderdetail extends AbstractDBElement implements TimeStampableInterface, N
|
|||
* Set this to "", if the function getSupplierProductURL should return the automatic generated URL.
|
||||
*
|
||||
* @param string $new_url The new URL for the supplier URL
|
||||
*
|
||||
* @return Orderdetail
|
||||
*/
|
||||
public function setSupplierProductUrl(string $new_url): self
|
||||
{
|
||||
|
|
|
@ -48,7 +48,7 @@ class Pricedetail extends AbstractDBElement implements TimeStampableInterface
|
|||
{
|
||||
use TimestampTrait;
|
||||
|
||||
public const PRICE_PRECISION = 5;
|
||||
final public const PRICE_PRECISION = 5;
|
||||
|
||||
/**
|
||||
* @var BigDecimal The price related to the detail. (Given in the selected currency)
|
||||
|
@ -119,7 +119,7 @@ class Pricedetail extends AbstractDBElement implements TimeStampableInterface
|
|||
public function updateTimestamps(): void
|
||||
{
|
||||
$this->lastModified = new DateTime('now');
|
||||
if (null === $this->addedDate) {
|
||||
if (!$this->addedDate instanceof \DateTimeInterface) {
|
||||
$this->addedDate = new DateTime('now');
|
||||
}
|
||||
|
||||
|
@ -166,7 +166,7 @@ class Pricedetail extends AbstractDBElement implements TimeStampableInterface
|
|||
*
|
||||
* @return BigDecimal the price as a bcmath string
|
||||
*/
|
||||
public function getPricePerUnit($multiplier = 1.0): BigDecimal
|
||||
public function getPricePerUnit(float|string|\Brick\Math\BigDecimal $multiplier = 1.0): BigDecimal
|
||||
{
|
||||
$tmp = BigDecimal::of($multiplier);
|
||||
$tmp = $tmp->multipliedBy($this->price);
|
||||
|
@ -248,8 +248,6 @@ class Pricedetail extends AbstractDBElement implements TimeStampableInterface
|
|||
/**
|
||||
* Sets the currency associated with the price information.
|
||||
* Set to null, to use the global base currency.
|
||||
*
|
||||
* @return Pricedetail
|
||||
*/
|
||||
public function setCurrency(?Currency $currency): self
|
||||
{
|
||||
|
|
|
@ -37,7 +37,7 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
|||
/**
|
||||
* Class AttachmentType.
|
||||
*/
|
||||
#[ORM\Entity(repositoryClass: 'App\Repository\Parts\DeviceRepository')]
|
||||
#[ORM\Entity(repositoryClass: \App\Repository\Parts\DeviceRepository::class)]
|
||||
#[ORM\Table(name: 'projects')]
|
||||
class Project extends AbstractStructuralDBElement
|
||||
{
|
||||
|
@ -50,7 +50,7 @@ class Project extends AbstractStructuralDBElement
|
|||
|
||||
#[ORM\ManyToOne(targetEntity: 'Project', inversedBy: 'children')]
|
||||
#[ORM\JoinColumn(name: 'parent_id')]
|
||||
protected ?AbstractStructuralDBElement $parent;
|
||||
protected ?AbstractStructuralDBElement $parent = null;
|
||||
|
||||
#[Assert\Valid]
|
||||
#[Groups(['extended', 'full'])]
|
||||
|
@ -72,7 +72,7 @@ class Project extends AbstractStructuralDBElement
|
|||
/**
|
||||
* @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::class, mappedBy: 'built_project', cascade: ['persist'], orphanRemoval: true)]
|
||||
protected ?Part $build_part = null;
|
||||
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN)]
|
||||
|
@ -85,13 +85,13 @@ class Project extends AbstractStructuralDBElement
|
|||
/**
|
||||
* @var Collection<int, ProjectAttachment>
|
||||
*/
|
||||
#[ORM\OneToMany(targetEntity: 'App\Entity\Attachments\ProjectAttachment', mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
|
||||
#[ORM\OneToMany(targetEntity: \App\Entity\Attachments\ProjectAttachment::class, mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
|
||||
#[ORM\OrderBy(['name' => 'ASC'])]
|
||||
protected Collection $attachments;
|
||||
|
||||
/** @var Collection<int, ProjectParameter>
|
||||
*/
|
||||
#[ORM\OneToMany(targetEntity: 'App\Entity\Parameters\ProjectParameter', mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
|
||||
#[ORM\OneToMany(targetEntity: \App\Entity\Parameters\ProjectParameter::class, mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
|
||||
#[ORM\OrderBy(['group' => 'ASC', 'name' => 'ASC'])]
|
||||
protected Collection $parameters;
|
||||
|
||||
|
@ -174,8 +174,6 @@ class Project extends AbstractStructuralDBElement
|
|||
* Set the "order_only_missing_parts" attribute.
|
||||
*
|
||||
* @param bool $new_order_only_missing_parts the new "order_only_missing_parts" attribute
|
||||
*
|
||||
* @return Project
|
||||
*/
|
||||
public function setOrderOnlyMissingParts(bool $new_order_only_missing_parts): self
|
||||
{
|
||||
|
@ -193,7 +191,6 @@ class Project extends AbstractStructuralDBElement
|
|||
}
|
||||
|
||||
/**
|
||||
* @param ProjectBOMEntry $entry
|
||||
* @return $this
|
||||
*/
|
||||
public function addBomEntry(ProjectBOMEntry $entry): self
|
||||
|
@ -204,7 +201,6 @@ class Project extends AbstractStructuralDBElement
|
|||
}
|
||||
|
||||
/**
|
||||
* @param ProjectBOMEntry $entry
|
||||
* @return $this
|
||||
*/
|
||||
public function removeBomEntry(ProjectBOMEntry $entry): self
|
||||
|
@ -213,18 +209,11 @@ class Project extends AbstractStructuralDBElement
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDescription(): string
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $description
|
||||
* @return Project
|
||||
*/
|
||||
public function setDescription(string $description): Project
|
||||
{
|
||||
$this->description = $description;
|
||||
|
@ -249,16 +238,14 @@ class Project extends AbstractStructuralDBElement
|
|||
|
||||
/**
|
||||
* Checks if this project has an associated part representing the builds of this project in the stock.
|
||||
* @return bool
|
||||
*/
|
||||
public function hasBuildPart(): bool
|
||||
{
|
||||
return $this->build_part !== null;
|
||||
return $this->build_part instanceof \App\Entity\Parts\Part;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the part representing the builds of this project in the stock, if it is existing
|
||||
* @return Part|null
|
||||
*/
|
||||
public function getBuildPart(): ?Part
|
||||
{
|
||||
|
@ -267,12 +254,11 @@ class Project extends AbstractStructuralDBElement
|
|||
|
||||
/**
|
||||
* Sets the part representing the builds of this project in the stock.
|
||||
* @param Part|null $build_part
|
||||
*/
|
||||
public function setBuildPart(?Part $build_part): void
|
||||
{
|
||||
$this->build_part = $build_part;
|
||||
if ($build_part) {
|
||||
if ($build_part instanceof \App\Entity\Parts\Part) {
|
||||
$build_part->setBuiltProject($this);
|
||||
}
|
||||
}
|
||||
|
@ -283,7 +269,7 @@ class Project extends AbstractStructuralDBElement
|
|||
//If this project has subprojects, and these have builds part, they must be included in the BOM
|
||||
foreach ($this->getChildren() as $child) {
|
||||
/** @var $child Project */
|
||||
if ($child->getBuildPart() === null) {
|
||||
if (!$child->getBuildPart() instanceof \App\Entity\Parts\Part) {
|
||||
continue;
|
||||
}
|
||||
//We have to search all bom entries for the build part
|
||||
|
|
|
@ -82,7 +82,7 @@ class ProjectBOMEntry extends AbstractDBElement
|
|||
/**
|
||||
* @var Part|null The part associated with this
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: 'App\Entity\Parts\Part', inversedBy: 'project_bom_entries')]
|
||||
#[ORM\ManyToOne(targetEntity: \App\Entity\Parts\Part::class, inversedBy: 'project_bom_entries')]
|
||||
#[ORM\JoinColumn(name: 'id_part')]
|
||||
protected ?Part $part = null;
|
||||
|
||||
|
@ -91,52 +91,36 @@ class ProjectBOMEntry extends AbstractDBElement
|
|||
*/
|
||||
#[Assert\AtLeastOneOf([new BigDecimalPositive(), new Assert\IsNull()])]
|
||||
#[ORM\Column(type: 'big_decimal', precision: 11, scale: 5, nullable: true)]
|
||||
protected ?BigDecimal $price;
|
||||
protected ?BigDecimal $price = null;
|
||||
|
||||
/**
|
||||
* @var ?Currency The currency for the price of this non-part BOM entry
|
||||
* @Selectable()
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: 'App\Entity\PriceInformations\Currency')]
|
||||
#[ORM\ManyToOne(targetEntity: \App\Entity\PriceInformations\Currency::class)]
|
||||
#[ORM\JoinColumn]
|
||||
protected ?Currency $price_currency = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
//$this->price = BigDecimal::zero()->toScale(5);
|
||||
$this->price = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getQuantity(): float
|
||||
{
|
||||
return $this->quantity;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float $quantity
|
||||
* @return ProjectBOMEntry
|
||||
*/
|
||||
public function setQuantity(float $quantity): ProjectBOMEntry
|
||||
{
|
||||
$this->quantity = $quantity;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getMountnames(): string
|
||||
{
|
||||
return $this->mountnames;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $mountnames
|
||||
* @return ProjectBOMEntry
|
||||
*/
|
||||
public function setMountnames(string $mountnames): ProjectBOMEntry
|
||||
{
|
||||
$this->mountnames = $mountnames;
|
||||
|
@ -153,7 +137,6 @@ class ProjectBOMEntry extends AbstractDBElement
|
|||
|
||||
/**
|
||||
* @param string $name
|
||||
* @return ProjectBOMEntry
|
||||
*/
|
||||
public function setName(?string $name): ProjectBOMEntry
|
||||
{
|
||||
|
@ -161,36 +144,22 @@ class ProjectBOMEntry extends AbstractDBElement
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getComment(): string
|
||||
{
|
||||
return $this->comment;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $comment
|
||||
* @return ProjectBOMEntry
|
||||
*/
|
||||
public function setComment(string $comment): ProjectBOMEntry
|
||||
{
|
||||
$this->comment = $comment;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Project|null
|
||||
*/
|
||||
public function getProject(): ?Project
|
||||
{
|
||||
return $this->project;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Project|null $project
|
||||
* @return ProjectBOMEntry
|
||||
*/
|
||||
public function setProject(?Project $project): ProjectBOMEntry
|
||||
{
|
||||
$this->project = $project;
|
||||
|
@ -199,18 +168,11 @@ class ProjectBOMEntry extends AbstractDBElement
|
|||
|
||||
|
||||
|
||||
/**
|
||||
* @return Part|null
|
||||
*/
|
||||
public function getPart(): ?Part
|
||||
{
|
||||
return $this->part;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Part|null $part
|
||||
* @return ProjectBOMEntry
|
||||
*/
|
||||
public function setPart(?Part $part): ProjectBOMEntry
|
||||
{
|
||||
$this->part = $part;
|
||||
|
@ -220,7 +182,6 @@ class ProjectBOMEntry extends AbstractDBElement
|
|||
/**
|
||||
* Returns the price of this BOM entry, if existing.
|
||||
* Prices are only valid on non-Part BOM entries.
|
||||
* @return BigDecimal|null
|
||||
*/
|
||||
public function getPrice(): ?BigDecimal
|
||||
{
|
||||
|
@ -230,24 +191,17 @@ class ProjectBOMEntry extends AbstractDBElement
|
|||
/**
|
||||
* Sets the price of this BOM entry.
|
||||
* Prices are only valid on non-Part BOM entries.
|
||||
* @param BigDecimal|null $price
|
||||
*/
|
||||
public function setPrice(?BigDecimal $price): void
|
||||
{
|
||||
$this->price = $price;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Currency|null
|
||||
*/
|
||||
public function getPriceCurrency(): ?Currency
|
||||
{
|
||||
return $this->price_currency;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Currency|null $price_currency
|
||||
*/
|
||||
public function setPriceCurrency(?Currency $price_currency): void
|
||||
{
|
||||
$this->price_currency = $price_currency;
|
||||
|
@ -259,20 +213,18 @@ class ProjectBOMEntry extends AbstractDBElement
|
|||
*/
|
||||
public function isPartBomEntry(): bool
|
||||
{
|
||||
return $this->part !== null;
|
||||
return $this->part instanceof \App\Entity\Parts\Part;
|
||||
}
|
||||
|
||||
#[Assert\Callback]
|
||||
public function validate(ExecutionContextInterface $context, $payload): void
|
||||
{
|
||||
//Round quantity to whole numbers, if the part is not a decimal part
|
||||
if ($this->part) {
|
||||
if (!$this->part->getPartUnit() || $this->part->getPartUnit()->isInteger()) {
|
||||
$this->quantity = round($this->quantity);
|
||||
}
|
||||
if ($this->part instanceof \App\Entity\Parts\Part && (!$this->part->getPartUnit() || $this->part->getPartUnit()->isInteger())) {
|
||||
$this->quantity = round($this->quantity);
|
||||
}
|
||||
//Non-Part BOM entries are rounded
|
||||
if ($this->part === null) {
|
||||
if (!$this->part instanceof \App\Entity\Parts\Part) {
|
||||
$this->quantity = round($this->quantity);
|
||||
}
|
||||
|
||||
|
@ -296,14 +248,14 @@ class ProjectBOMEntry extends AbstractDBElement
|
|||
}
|
||||
|
||||
//Prices are only allowed on non-part BOM entries
|
||||
if ($this->part !== null && $this->price !== null) {
|
||||
if ($this->part instanceof \App\Entity\Parts\Part && $this->price instanceof \Brick\Math\BigDecimal) {
|
||||
$context->buildViolation('project.bom_entry.price_not_allowed_on_parts')
|
||||
->atPath('price')
|
||||
->addViolation();
|
||||
}
|
||||
|
||||
//Check that the part is not the build representation part of this device or one of its parents
|
||||
if ($this->part && $this->part->getBuiltProject() !== null) {
|
||||
if ($this->part && $this->part->getBuiltProject() instanceof \App\Entity\ProjectSystem\Project) {
|
||||
//Get the associated project
|
||||
$associated_project = $this->part->getBuiltProject();
|
||||
//Check that it is not the same as the current project neither one of its parents
|
||||
|
|
|
@ -51,7 +51,7 @@ class Group extends AbstractStructuralDBElement implements HasPermissionsInterfa
|
|||
|
||||
#[ORM\ManyToOne(targetEntity: 'Group', inversedBy: 'children')]
|
||||
#[ORM\JoinColumn(name: 'parent_id')]
|
||||
protected ?AbstractStructuralDBElement $parent;
|
||||
protected ?AbstractStructuralDBElement $parent = null;
|
||||
|
||||
/**
|
||||
* @var Collection<int, User>
|
||||
|
@ -69,7 +69,7 @@ class Group extends AbstractStructuralDBElement implements HasPermissionsInterfa
|
|||
* @var Collection<int, GroupAttachment>
|
||||
*/
|
||||
#[Assert\Valid]
|
||||
#[ORM\OneToMany(targetEntity: 'App\Entity\Attachments\GroupAttachment', mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
|
||||
#[ORM\OneToMany(targetEntity: \App\Entity\Attachments\GroupAttachment::class, mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
|
||||
#[ORM\OrderBy(['name' => 'ASC'])]
|
||||
protected Collection $attachments;
|
||||
|
||||
|
@ -84,7 +84,7 @@ class Group extends AbstractStructuralDBElement implements HasPermissionsInterfa
|
|||
/** @var Collection<int, GroupParameter>
|
||||
*/
|
||||
#[Assert\Valid]
|
||||
#[ORM\OneToMany(targetEntity: 'App\Entity\Parameters\GroupParameter', mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
|
||||
#[ORM\OneToMany(targetEntity: \App\Entity\Parameters\GroupParameter::class, mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
|
||||
#[ORM\OrderBy(['group' => 'ASC', 'name' => 'ASC'])]
|
||||
protected Collection $parameters;
|
||||
|
||||
|
@ -122,7 +122,7 @@ class Group extends AbstractStructuralDBElement implements HasPermissionsInterfa
|
|||
|
||||
public function getPermissions(): PermissionData
|
||||
{
|
||||
if ($this->permissions === null) {
|
||||
if (!$this->permissions instanceof \App\Entity\UserSystem\PermissionData) {
|
||||
$this->permissions = new PermissionData();
|
||||
}
|
||||
|
||||
|
|
|
@ -42,6 +42,10 @@ final class PermissionData implements \JsonSerializable
|
|||
public const CURRENT_SCHEMA_VERSION = 2;
|
||||
|
||||
/**
|
||||
* Creates a new Permission Data Instance using the given data.
|
||||
* By default, an empty array is used, meaning
|
||||
*/
|
||||
public function __construct(/**
|
||||
* @var array|null This array contains the permission values for each permission
|
||||
* This array contains the permission values for each permission, in the form of:
|
||||
* permission => [
|
||||
|
@ -49,19 +53,8 @@ final class PermissionData implements \JsonSerializable
|
|||
* ]
|
||||
*/
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON, name: 'data')]
|
||||
protected ?array $data = [
|
||||
//$ prefixed entries are used for metadata
|
||||
'$ver' => self::CURRENT_SCHEMA_VERSION, //The schema version of the permission data
|
||||
];
|
||||
|
||||
/**
|
||||
* Creates a new Permission Data Instance using the given data.
|
||||
* By default, an empty array is used, meaning
|
||||
*/
|
||||
public function __construct(array $data = [])
|
||||
protected array $data = [])
|
||||
{
|
||||
$this->data = $data;
|
||||
|
||||
//If the passed data did not contain a schema version, we set it to the current version
|
||||
if (!isset($this->data['$ver'])) {
|
||||
$this->data['$ver'] = self::CURRENT_SCHEMA_VERSION;
|
||||
|
@ -70,8 +63,6 @@ final class PermissionData implements \JsonSerializable
|
|||
|
||||
/**
|
||||
* Checks if any of the operations of the given permission is defined (meaning it is either ALLOW or DENY)
|
||||
* @param string $permission
|
||||
* @return bool
|
||||
*/
|
||||
public function isAnyOperationOfPermissionSet(string $permission): bool
|
||||
{
|
||||
|
@ -80,7 +71,6 @@ final class PermissionData implements \JsonSerializable
|
|||
|
||||
/**
|
||||
* Returns an associative array containing all defined (non-INHERIT) operations of the given permission.
|
||||
* @param string $permission
|
||||
* @return array An array in the form ["operation" => value], returns an empty array if no operations are defined
|
||||
*/
|
||||
public function getAllDefinedOperationsOfPermission(string $permission): array
|
||||
|
@ -95,8 +85,6 @@ final class PermissionData implements \JsonSerializable
|
|||
/**
|
||||
* Sets all operations of the given permission via the given array.
|
||||
* The data is an array in the form [$operation => $value], all existing values will be overwritten/deleted.
|
||||
* @param string $permission
|
||||
* @param array $data
|
||||
* @return $this
|
||||
*/
|
||||
public function setAllOperationsOfPermission(string $permission, array $data): self
|
||||
|
@ -108,7 +96,6 @@ final class PermissionData implements \JsonSerializable
|
|||
|
||||
/**
|
||||
* Removes a whole permission from the data including all operations (effectivly setting them to INHERIT)
|
||||
* @param string $permission
|
||||
* @return $this
|
||||
*/
|
||||
public function removePermission(string $permission): self
|
||||
|
@ -120,8 +107,6 @@ final class PermissionData implements \JsonSerializable
|
|||
|
||||
/**
|
||||
* Check if a permission value is set for the given permission and operation (meaning there value is not inherit).
|
||||
* @param string $permission
|
||||
* @param string $operation
|
||||
* @return bool True if the permission value is set, false otherwise
|
||||
*/
|
||||
public function isPermissionSet(string $permission, string $operation): bool
|
||||
|
@ -136,8 +121,6 @@ final class PermissionData implements \JsonSerializable
|
|||
|
||||
/**
|
||||
* Returns the permission value for the given permission and operation.
|
||||
* @param string $permission
|
||||
* @param string $operation
|
||||
* @return bool|null True means allow, false means disallow, null means inherit
|
||||
*/
|
||||
public function getPermissionValue(string $permission, string $operation): ?bool
|
||||
|
@ -152,9 +135,6 @@ final class PermissionData implements \JsonSerializable
|
|||
|
||||
/**
|
||||
* Sets the permission value for the given permission and operation.
|
||||
* @param string $permission
|
||||
* @param string $operation
|
||||
* @param bool|null $value
|
||||
* @return $this
|
||||
*/
|
||||
public function setPermissionValue(string $permission, string $operation, ?bool $value): self
|
||||
|
@ -185,8 +165,6 @@ final class PermissionData implements \JsonSerializable
|
|||
|
||||
/**
|
||||
* Creates a new Permission Data Instance using the given JSON encoded data
|
||||
* @param string $json
|
||||
* @return static
|
||||
* @throws \JsonException
|
||||
*/
|
||||
public static function fromJSON(string $json): self
|
||||
|
@ -202,7 +180,6 @@ final class PermissionData implements \JsonSerializable
|
|||
|
||||
/**
|
||||
* Returns an JSON encodable representation of this object.
|
||||
* @return array
|
||||
*/
|
||||
public function jsonSerialize(): array
|
||||
{
|
||||
|
@ -215,9 +192,7 @@ final class PermissionData implements \JsonSerializable
|
|||
continue;
|
||||
}
|
||||
|
||||
$ret[$permission] = array_filter($operations, static function ($value) {
|
||||
return $value !== null;
|
||||
});
|
||||
$ret[$permission] = array_filter($operations, static fn($value) => $value !== null);
|
||||
|
||||
//If the permission has no operations, unset it
|
||||
if (empty($ret[$permission])) {
|
||||
|
@ -239,7 +214,6 @@ final class PermissionData implements \JsonSerializable
|
|||
|
||||
/**
|
||||
* Sets the schema version of this permission data
|
||||
* @param int $new_version
|
||||
* @return $this
|
||||
*/
|
||||
public function setSchemaVersion(int $new_version): self
|
||||
|
|
|
@ -73,7 +73,7 @@ class U2FKey implements LegacyU2FKeyInterface
|
|||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING)]
|
||||
protected string $name;
|
||||
|
||||
#[ORM\ManyToOne(targetEntity: 'App\Entity\UserSystem\User', inversedBy: 'u2fKeys')]
|
||||
#[ORM\ManyToOne(targetEntity: \App\Entity\UserSystem\User::class, inversedBy: 'u2fKeys')]
|
||||
protected ?User $user = null;
|
||||
|
||||
public function getKeyHandle(): string
|
||||
|
|
|
@ -56,8 +56,8 @@ use Jbtronics\TFAWebauthn\Model\TwoFactorInterface as WebauthnTwoFactorInterface
|
|||
* Also, this entity is able to save some information about the user, like the names, email-address and other info.
|
||||
*/
|
||||
#[UniqueEntity('name', message: 'validator.user.username_already_used')]
|
||||
#[ORM\Entity(repositoryClass: 'App\Repository\UserRepository')]
|
||||
#[ORM\EntityListeners(['App\EntityListeners\TreeCacheInvalidationListener'])]
|
||||
#[ORM\Entity(repositoryClass: \App\Repository\UserRepository::class)]
|
||||
#[ORM\EntityListeners([\App\EntityListeners\TreeCacheInvalidationListener::class])]
|
||||
#[ORM\Table('`users`')]
|
||||
#[ORM\Index(name: 'user_idx_username', columns: ['name'])]
|
||||
class User extends AttachmentContainingDBElement implements UserInterface, HasPermissionsInterface, TwoFactorInterface,
|
||||
|
@ -68,7 +68,7 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
|
|||
/**
|
||||
* The User id of the anonymous user.
|
||||
*/
|
||||
public const ID_ANONYMOUS = 1;
|
||||
final public const ID_ANONYMOUS = 1;
|
||||
|
||||
/**
|
||||
* @var bool Determines if the user is disabled (user can not log in)
|
||||
|
@ -214,7 +214,7 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
|
|||
/**
|
||||
* @var Collection<int, UserAttachment>
|
||||
*/
|
||||
#[ORM\OneToMany(targetEntity: 'App\Entity\Attachments\UserAttachment', mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
|
||||
#[ORM\OneToMany(targetEntity: \App\Entity\Attachments\UserAttachment::class, mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
|
||||
#[ORM\OrderBy(['name' => 'ASC'])]
|
||||
protected Collection $attachments;
|
||||
|
||||
|
@ -226,13 +226,13 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
|
|||
|
||||
/** @var Collection<int, LegacyU2FKeyInterface>
|
||||
*/
|
||||
#[ORM\OneToMany(targetEntity: 'App\Entity\UserSystem\U2FKey', mappedBy: 'user', cascade: ['REMOVE'], orphanRemoval: true)]
|
||||
#[ORM\OneToMany(targetEntity: \App\Entity\UserSystem\U2FKey::class, mappedBy: 'user', cascade: ['REMOVE'], orphanRemoval: true)]
|
||||
protected Collection $u2fKeys;
|
||||
|
||||
/**
|
||||
* @var Collection<int, WebauthnKey>
|
||||
*/
|
||||
#[ORM\OneToMany(targetEntity: 'App\Entity\UserSystem\WebauthnKey', mappedBy: 'user', cascade: ['REMOVE'], orphanRemoval: true)]
|
||||
#[ORM\OneToMany(targetEntity: \App\Entity\UserSystem\WebauthnKey::class, mappedBy: 'user', cascade: ['REMOVE'], orphanRemoval: true)]
|
||||
protected Collection $webauthn_keys;
|
||||
|
||||
/**
|
||||
|
@ -243,9 +243,9 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
|
|||
* @Selectable()
|
||||
*/
|
||||
#[Groups(['extended', 'full', 'import'])]
|
||||
#[ORM\ManyToOne(targetEntity: 'App\Entity\PriceInformations\Currency')]
|
||||
#[ORM\ManyToOne(targetEntity: \App\Entity\PriceInformations\Currency::class)]
|
||||
#[ORM\JoinColumn(name: 'currency_id')]
|
||||
protected ?Currency $currency;
|
||||
protected ?Currency $currency = null;
|
||||
|
||||
/**
|
||||
* @var PermissionData|null
|
||||
|
@ -259,7 +259,7 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
|
|||
* @var \DateTimeInterface|null the time until the password reset token is valid
|
||||
*/
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_MUTABLE, nullable: true)]
|
||||
protected ?\DateTimeInterface $pw_reset_expires;
|
||||
protected ?\DateTimeInterface $pw_reset_expires = null;
|
||||
|
||||
/**
|
||||
* @var bool True if the user was created by a SAML provider (and therefore cannot change its password)
|
||||
|
@ -350,8 +350,6 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
|
|||
|
||||
/**
|
||||
* Sets the password hash for this user.
|
||||
*
|
||||
* @return User
|
||||
*/
|
||||
public function setPassword(string $password): self
|
||||
{
|
||||
|
@ -389,8 +387,6 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
|
|||
|
||||
/**
|
||||
* Sets the currency the users prefers to see prices in.
|
||||
*
|
||||
* @return User
|
||||
*/
|
||||
public function setCurrency(?Currency $currency): self
|
||||
{
|
||||
|
@ -413,8 +409,6 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
|
|||
* Sets the status if a user is disabled.
|
||||
*
|
||||
* @param bool $disabled true if the user should be disabled
|
||||
*
|
||||
* @return User
|
||||
*/
|
||||
public function setDisabled(bool $disabled): self
|
||||
{
|
||||
|
@ -425,7 +419,7 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
|
|||
|
||||
public function getPermissions(): PermissionData
|
||||
{
|
||||
if ($this->permissions === null) {
|
||||
if (!$this->permissions instanceof \App\Entity\UserSystem\PermissionData) {
|
||||
$this->permissions = new PermissionData();
|
||||
}
|
||||
|
||||
|
@ -442,8 +436,6 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
|
|||
|
||||
/**
|
||||
* Set the status, if the user needs a password change.
|
||||
*
|
||||
* @return User
|
||||
*/
|
||||
public function setNeedPwChange(bool $need_pw_change): self
|
||||
{
|
||||
|
@ -462,8 +454,6 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
|
|||
|
||||
/**
|
||||
* Sets the encrypted password reset token.
|
||||
*
|
||||
* @return User
|
||||
*/
|
||||
public function setPwResetToken(?string $pw_reset_token): self
|
||||
{
|
||||
|
@ -482,8 +472,6 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
|
|||
|
||||
/**
|
||||
* Sets the datetime when the password reset token expires.
|
||||
*
|
||||
* @return User
|
||||
*/
|
||||
public function setPwResetExpires(\DateTimeInterface $pw_reset_expires): self
|
||||
{
|
||||
|
@ -595,8 +583,6 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
|
|||
* Change the department of the user.
|
||||
*
|
||||
* @param string|null $department The new department
|
||||
*
|
||||
* @return User
|
||||
*/
|
||||
public function setDepartment(?string $department): self
|
||||
{
|
||||
|
@ -631,7 +617,6 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
|
|||
|
||||
/**
|
||||
* Gets whether the email address of the user is shown on the public profile page.
|
||||
* @return bool
|
||||
*/
|
||||
public function isShowEmailOnProfile(): bool
|
||||
{
|
||||
|
@ -640,8 +625,6 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
|
|||
|
||||
/**
|
||||
* Sets whether the email address of the user is shown on the public profile page.
|
||||
* @param bool $show_email_on_profile
|
||||
* @return User
|
||||
*/
|
||||
public function setShowEmailOnProfile(bool $show_email_on_profile): User
|
||||
{
|
||||
|
@ -653,7 +636,6 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
|
|||
|
||||
/**
|
||||
* Returns the about me text of the user.
|
||||
* @return string
|
||||
*/
|
||||
public function getAboutMe(): string
|
||||
{
|
||||
|
@ -662,8 +644,6 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
|
|||
|
||||
/**
|
||||
* Change the about me text of the user.
|
||||
* @param string $aboutMe
|
||||
* @return User
|
||||
*/
|
||||
public function setAboutMe(string $aboutMe): User
|
||||
{
|
||||
|
@ -689,8 +669,6 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
|
|||
*
|
||||
* @param string|null $language The new language as 2-letter ISO code (e.g. 'en' or 'de').
|
||||
* Set to null, to use the system-wide language.
|
||||
*
|
||||
* @return User
|
||||
*/
|
||||
public function setLanguage(?string $language): self
|
||||
{
|
||||
|
@ -855,11 +833,7 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
|
|||
public function setBackupCodes(array $codes): self
|
||||
{
|
||||
$this->backupCodes = $codes;
|
||||
if (empty($codes)) {
|
||||
$this->backupCodesGenerationDate = null;
|
||||
} else {
|
||||
$this->backupCodesGenerationDate = new DateTime();
|
||||
}
|
||||
$this->backupCodesGenerationDate = $codes === [] ? null : new DateTime();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
@ -938,7 +912,6 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
|
|||
|
||||
/**
|
||||
* Returns true, if the user was created by the SAML authentication.
|
||||
* @return bool
|
||||
*/
|
||||
public function isSamlUser(): bool
|
||||
{
|
||||
|
@ -947,8 +920,6 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
|
|||
|
||||
/**
|
||||
* Sets the saml_user flag.
|
||||
* @param bool $saml_user
|
||||
* @return User
|
||||
*/
|
||||
public function setSamlUser(bool $saml_user): User
|
||||
{
|
||||
|
|
|
@ -39,48 +39,31 @@ class WebauthnKey extends BasePublicKeyCredentialSource
|
|||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING)]
|
||||
protected string $name;
|
||||
|
||||
#[ORM\ManyToOne(targetEntity: 'App\Entity\UserSystem\User', inversedBy: 'webauthn_keys')]
|
||||
#[ORM\ManyToOne(targetEntity: \App\Entity\UserSystem\User::class, inversedBy: 'webauthn_keys')]
|
||||
protected ?User $user = null;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @return WebauthnKey
|
||||
*/
|
||||
public function setName(string $name): WebauthnKey
|
||||
{
|
||||
$this->name = $name;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return User|null
|
||||
*/
|
||||
public function getUser(): ?User
|
||||
{
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param User|null $user
|
||||
* @return WebauthnKey
|
||||
*/
|
||||
public function setUser(?User $user): WebauthnKey
|
||||
{
|
||||
$this->user = $user;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getId(): int
|
||||
{
|
||||
return $this->id;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue