Use imports instead of FQNs

This commit is contained in:
Jan Böhmer 2023-06-11 14:55:06 +02:00
parent f63b6d7207
commit 5629215ce4
179 changed files with 792 additions and 597 deletions

View file

@ -22,6 +22,9 @@ declare(strict_types=1);
namespace App\Entity\Attachments;
use App\Repository\AttachmentRepository;
use App\EntityListeners\AttachmentDeleteListener;
use Doctrine\DBAL\Types\Types;
use App\Entity\Base\AbstractNamedDBElement;
use App\Validator\Constraints\Selectable;
use Doctrine\ORM\Mapping as ORM;
@ -34,11 +37,11 @@ use LogicException;
/**
* Class Attachment.
*/
#[ORM\Entity(repositoryClass: \App\Repository\AttachmentRepository::class)]
#[ORM\Entity(repositoryClass: 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::class])]
#[ORM\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'])]
@ -78,13 +81,13 @@ abstract class Attachment extends AbstractNamedDBElement
/**
* @var string|null the original filename the file had, when the user uploaded it
*/
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, nullable: true)]
#[ORM\Column(type: Types::STRING, nullable: true)]
protected ?string $original_filename = null;
/**
* @var string The path to the file relative to a placeholder path like %MEDIA%
*/
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, name: 'path')]
#[ORM\Column(type: Types::STRING, name: 'path')]
protected string $path = '';
/**
@ -92,7 +95,7 @@ abstract class Attachment extends AbstractNamedDBElement
*/
#[Assert\NotBlank(message: 'validator.attachment.name_not_blank')]
#[Groups(['simple', 'extended', 'full'])]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING)]
#[ORM\Column(type: Types::STRING)]
protected string $name = '';
/**
@ -103,7 +106,7 @@ abstract class Attachment extends AbstractNamedDBElement
/**
* @var bool
*/
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN)]
#[ORM\Column(type: Types::BOOLEAN)]
protected bool $show_in_table = false;
/**

View file

@ -22,6 +22,8 @@ declare(strict_types=1);
namespace App\Entity\Attachments;
use App\Repository\StructuralDBElementRepository;
use Doctrine\DBAL\Types\Types;
use App\Entity\Base\AbstractStructuralDBElement;
use App\Entity\Parameters\AttachmentTypeParameter;
use App\Validator\Constraints\ValidFileFilter;
@ -33,7 +35,7 @@ use Symfony\Component\Validator\Constraints as Assert;
/**
* Class AttachmentType.
*/
#[ORM\Entity(repositoryClass: \App\Repository\StructuralDBElementRepository::class)]
#[ORM\Entity(repositoryClass: 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'])]
@ -51,33 +53,36 @@ class AttachmentType extends AbstractStructuralDBElement
* @var string
* @ValidFileFilter
*/
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT)]
#[ORM\Column(type: Types::TEXT)]
protected string $filetype_filter = '';
/**
* @var Collection<int, AttachmentTypeAttachment>
*/
#[Assert\Valid]
#[ORM\OneToMany(targetEntity: \App\Entity\Attachments\AttachmentTypeAttachment::class, mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
#[ORM\OneToMany(targetEntity: 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::class, mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
#[ORM\OneToMany(targetEntity: AttachmentTypeParameter::class, mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
#[ORM\OrderBy(['group' => 'ASC', 'name' => 'ASC'])]
protected Collection $parameters;
/**
* @var \Doctrine\Common\Collections\Collection<\App\Entity\Attachments\Attachment>
* @var Collection<Attachment>
*/
/**
* @var Collection<Attachment>
*/
#[ORM\OneToMany(targetEntity: 'Attachment', mappedBy: 'attachment_type')]
protected \Doctrine\Common\Collections\Collection $attachments_with_type;
protected Collection $attachments_with_type;
public function __construct()
{
$this->children = new \Doctrine\Common\Collections\ArrayCollection();
$this->parameters = new \Doctrine\Common\Collections\ArrayCollection();
$this->children = new ArrayCollection();
$this->parameters = new ArrayCollection();
parent::__construct();
$this->attachments = new ArrayCollection();
$this->attachments_with_type = new ArrayCollection();

View file

@ -36,7 +36,7 @@ class AttachmentTypeAttachment extends Attachment
/**
* @var AttachmentContainingDBElement|null the element this attachment is associated with
*/
#[ORM\ManyToOne(targetEntity: \App\Entity\Attachments\AttachmentType::class, inversedBy: 'attachments')]
#[ORM\ManyToOne(targetEntity: AttachmentType::class, inversedBy: 'attachments')]
#[ORM\JoinColumn(name: 'element_id', nullable: false, onDelete: 'CASCADE')]
protected ?AttachmentContainingDBElement $element = null;
}

View file

@ -37,7 +37,7 @@ class CategoryAttachment extends Attachment
/**
* @var AttachmentContainingDBElement|null the element this attachment is associated with
*/
#[ORM\ManyToOne(targetEntity: \App\Entity\Parts\Category::class, inversedBy: 'attachments')]
#[ORM\ManyToOne(targetEntity: Category::class, inversedBy: 'attachments')]
#[ORM\JoinColumn(name: 'element_id', nullable: false, onDelete: 'CASCADE')]
protected ?AttachmentContainingDBElement $element = null;
}

View file

@ -37,7 +37,7 @@ class CurrencyAttachment extends Attachment
/**
* @var Currency|null the element this attachment is associated with
*/
#[ORM\ManyToOne(targetEntity: \App\Entity\PriceInformations\Currency::class, inversedBy: 'attachments')]
#[ORM\ManyToOne(targetEntity: Currency::class, inversedBy: 'attachments')]
#[ORM\JoinColumn(name: 'element_id', nullable: false, onDelete: 'CASCADE')]
protected ?AttachmentContainingDBElement $element = null;
}

View file

@ -37,7 +37,7 @@ class FootprintAttachment extends Attachment
/**
* @var Footprint|null the element this attachment is associated with
*/
#[ORM\ManyToOne(targetEntity: \App\Entity\Parts\Footprint::class, inversedBy: 'attachments')]
#[ORM\ManyToOne(targetEntity: Footprint::class, inversedBy: 'attachments')]
#[ORM\JoinColumn(name: 'element_id', nullable: false, onDelete: 'CASCADE')]
protected ?AttachmentContainingDBElement $element = null;
}

View file

@ -38,7 +38,7 @@ class GroupAttachment extends Attachment
/**
* @var Group|null the element this attachment is associated with
*/
#[ORM\ManyToOne(targetEntity: \App\Entity\UserSystem\Group::class, inversedBy: 'attachments')]
#[ORM\ManyToOne(targetEntity: Group::class, inversedBy: 'attachments')]
#[ORM\JoinColumn(name: 'element_id', nullable: false, onDelete: 'CASCADE')]
protected ?AttachmentContainingDBElement $element = null;
}

View file

@ -57,7 +57,7 @@ class LabelAttachment extends Attachment
/**
* @var LabelProfile the element this attachment is associated with
*/
#[ORM\ManyToOne(targetEntity: \App\Entity\LabelSystem\LabelProfile::class, inversedBy: 'attachments')]
#[ORM\ManyToOne(targetEntity: LabelProfile::class, inversedBy: 'attachments')]
#[ORM\JoinColumn(name: 'element_id', nullable: false, onDelete: 'CASCADE')]
protected ?AttachmentContainingDBElement $element = null;
}

View file

@ -38,7 +38,7 @@ class ManufacturerAttachment extends Attachment
/**
* @var Manufacturer|null the element this attachment is associated with
*/
#[ORM\ManyToOne(targetEntity: \App\Entity\Parts\Manufacturer::class, inversedBy: 'attachments')]
#[ORM\ManyToOne(targetEntity: Manufacturer::class, inversedBy: 'attachments')]
#[ORM\JoinColumn(name: 'element_id', nullable: false, onDelete: 'CASCADE')]
protected ?AttachmentContainingDBElement $element = null;
}

View file

@ -38,7 +38,7 @@ class MeasurementUnitAttachment extends Attachment
/**
* @var Manufacturer|null the element this attachment is associated with
*/
#[ORM\ManyToOne(targetEntity: \App\Entity\Parts\MeasurementUnit::class, inversedBy: 'attachments')]
#[ORM\ManyToOne(targetEntity: MeasurementUnit::class, inversedBy: 'attachments')]
#[ORM\JoinColumn(name: 'element_id', nullable: false, onDelete: 'CASCADE')]
protected ?AttachmentContainingDBElement $element = null;
}

View file

@ -37,7 +37,7 @@ class PartAttachment extends Attachment
/**
* @var Part the element this attachment is associated with
*/
#[ORM\ManyToOne(targetEntity: \App\Entity\Parts\Part::class, inversedBy: 'attachments')]
#[ORM\ManyToOne(targetEntity: Part::class, inversedBy: 'attachments')]
#[ORM\JoinColumn(name: 'element_id', nullable: false, onDelete: 'CASCADE')]
protected ?AttachmentContainingDBElement $element = null;
}

View file

@ -37,7 +37,7 @@ class ProjectAttachment extends Attachment
/**
* @var Project|null the element this attachment is associated with
*/
#[ORM\ManyToOne(targetEntity: \App\Entity\ProjectSystem\Project::class, inversedBy: 'attachments')]
#[ORM\ManyToOne(targetEntity: Project::class, inversedBy: 'attachments')]
#[ORM\JoinColumn(name: 'element_id', nullable: false, onDelete: 'CASCADE')]
protected ?AttachmentContainingDBElement $element = null;
}

View file

@ -38,7 +38,7 @@ class StorelocationAttachment extends Attachment
/**
* @var Storelocation|null the element this attachment is associated with
*/
#[ORM\ManyToOne(targetEntity: \App\Entity\Parts\Storelocation::class, inversedBy: 'attachments')]
#[ORM\ManyToOne(targetEntity: Storelocation::class, inversedBy: 'attachments')]
#[ORM\JoinColumn(name: 'element_id', nullable: false, onDelete: 'CASCADE')]
protected ?AttachmentContainingDBElement $element = null;
}

View file

@ -38,7 +38,7 @@ class SupplierAttachment extends Attachment
/**
* @var Supplier|null the element this attachment is associated with
*/
#[ORM\ManyToOne(targetEntity: \App\Entity\Parts\Supplier::class, inversedBy: 'attachments')]
#[ORM\ManyToOne(targetEntity: Supplier::class, inversedBy: 'attachments')]
#[ORM\JoinColumn(name: 'element_id', nullable: false, onDelete: 'CASCADE')]
protected ?AttachmentContainingDBElement $element = null;
}

View file

@ -38,7 +38,7 @@ class UserAttachment extends Attachment
/**
* @var User|null the element this attachment is associated with
*/
#[ORM\ManyToOne(targetEntity: \App\Entity\UserSystem\User::class, inversedBy: 'attachments')]
#[ORM\ManyToOne(targetEntity: User::class, inversedBy: 'attachments')]
#[ORM\JoinColumn(name: 'element_id', nullable: false, onDelete: 'CASCADE')]
protected ?AttachmentContainingDBElement $element = null;
}