From 41df76e8e64d7fd3cfcb829972b49e6370a32f52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Mon, 30 Mar 2020 16:01:00 +0200 Subject: [PATCH] Enforce unique names for attachments (per attachment type and part) --- src/Entity/Attachments/AttachmentTypeAttachment.php | 2 ++ src/Entity/Attachments/CategoryAttachment.php | 2 ++ src/Entity/Attachments/CurrencyAttachment.php | 2 ++ src/Entity/Attachments/DeviceAttachment.php | 2 ++ src/Entity/Attachments/FootprintAttachment.php | 2 ++ src/Entity/Attachments/GroupAttachment.php | 2 ++ src/Entity/Attachments/ManufacturerAttachment.php | 2 ++ src/Entity/Attachments/MeasurementUnitAttachment.php | 2 ++ src/Entity/Attachments/PartAttachment.php | 2 ++ src/Entity/Attachments/StorelocationAttachment.php | 2 ++ src/Entity/Attachments/SupplierAttachment.php | 2 ++ src/Entity/Attachments/UserAttachment.php | 2 ++ 12 files changed, 24 insertions(+) diff --git a/src/Entity/Attachments/AttachmentTypeAttachment.php b/src/Entity/Attachments/AttachmentTypeAttachment.php index 946964a4..f95c91c6 100644 --- a/src/Entity/Attachments/AttachmentTypeAttachment.php +++ b/src/Entity/Attachments/AttachmentTypeAttachment.php @@ -43,11 +43,13 @@ declare(strict_types=1); namespace App\Entity\Attachments; use Doctrine\ORM\Mapping as ORM; +use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; /** * A attachment attached to an attachmentType element. * * @ORM\Entity() + * @UniqueEntity({"name", "attachment_type", "element"}) */ class AttachmentTypeAttachment extends Attachment { diff --git a/src/Entity/Attachments/CategoryAttachment.php b/src/Entity/Attachments/CategoryAttachment.php index a700d238..bf25fd53 100644 --- a/src/Entity/Attachments/CategoryAttachment.php +++ b/src/Entity/Attachments/CategoryAttachment.php @@ -44,11 +44,13 @@ namespace App\Entity\Attachments; use App\Entity\Parts\Category; use Doctrine\ORM\Mapping as ORM; +use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; /** * A attachment attached to a category element. * * @ORM\Entity() + * @UniqueEntity({"name", "attachment_type", "element"}) */ class CategoryAttachment extends Attachment { diff --git a/src/Entity/Attachments/CurrencyAttachment.php b/src/Entity/Attachments/CurrencyAttachment.php index 101e33c8..1e49b9a2 100644 --- a/src/Entity/Attachments/CurrencyAttachment.php +++ b/src/Entity/Attachments/CurrencyAttachment.php @@ -44,11 +44,13 @@ namespace App\Entity\Attachments; use App\Entity\PriceInformations\Currency; use Doctrine\ORM\Mapping as ORM; +use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; /** * A attachment attached to a currency element. * * @ORM\Entity() + * @UniqueEntity({"name", "attachment_type", "element"}) */ class CurrencyAttachment extends Attachment { diff --git a/src/Entity/Attachments/DeviceAttachment.php b/src/Entity/Attachments/DeviceAttachment.php index af347160..93f2235b 100644 --- a/src/Entity/Attachments/DeviceAttachment.php +++ b/src/Entity/Attachments/DeviceAttachment.php @@ -44,11 +44,13 @@ namespace App\Entity\Attachments; use App\Entity\Devices\Device; use Doctrine\ORM\Mapping as ORM; +use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; /** * A attachment attached to a device element. * * @ORM\Entity() + * @UniqueEntity({"name", "attachment_type", "element"}) */ class DeviceAttachment extends Attachment { diff --git a/src/Entity/Attachments/FootprintAttachment.php b/src/Entity/Attachments/FootprintAttachment.php index 602c99d4..5335c0d0 100644 --- a/src/Entity/Attachments/FootprintAttachment.php +++ b/src/Entity/Attachments/FootprintAttachment.php @@ -44,11 +44,13 @@ namespace App\Entity\Attachments; use App\Entity\Parts\Footprint; use Doctrine\ORM\Mapping as ORM; +use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; /** * A attachment attached to a footprint element. * * @ORM\Entity() + * @UniqueEntity({"name", "attachment_type", "element"}) */ class FootprintAttachment extends Attachment { diff --git a/src/Entity/Attachments/GroupAttachment.php b/src/Entity/Attachments/GroupAttachment.php index 24d2414e..dfc592af 100644 --- a/src/Entity/Attachments/GroupAttachment.php +++ b/src/Entity/Attachments/GroupAttachment.php @@ -44,11 +44,13 @@ namespace App\Entity\Attachments; use App\Entity\UserSystem\Group; use Doctrine\ORM\Mapping as ORM; +use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; /** * A attachment attached to a Group element. * * @ORM\Entity() + * @UniqueEntity({"name", "attachment_type", "element"}) */ class GroupAttachment extends Attachment { diff --git a/src/Entity/Attachments/ManufacturerAttachment.php b/src/Entity/Attachments/ManufacturerAttachment.php index 443ba645..73c499a1 100644 --- a/src/Entity/Attachments/ManufacturerAttachment.php +++ b/src/Entity/Attachments/ManufacturerAttachment.php @@ -44,11 +44,13 @@ namespace App\Entity\Attachments; use App\Entity\Parts\Manufacturer; use Doctrine\ORM\Mapping as ORM; +use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; /** * A attachment attached to a manufacturer element. * * @ORM\Entity() + * @UniqueEntity({"name", "attachment_type", "element"}) */ class ManufacturerAttachment extends Attachment { diff --git a/src/Entity/Attachments/MeasurementUnitAttachment.php b/src/Entity/Attachments/MeasurementUnitAttachment.php index 3d85443d..6ba813fc 100644 --- a/src/Entity/Attachments/MeasurementUnitAttachment.php +++ b/src/Entity/Attachments/MeasurementUnitAttachment.php @@ -45,11 +45,13 @@ namespace App\Entity\Attachments; use App\Entity\Parts\Manufacturer; use App\Entity\Parts\MeasurementUnit; use Doctrine\ORM\Mapping as ORM; +use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; /** * A attachment attached to a measurement unit element. * * @ORM\Entity() + * @UniqueEntity({"name", "attachment_type", "element"}) */ class MeasurementUnitAttachment extends Attachment { diff --git a/src/Entity/Attachments/PartAttachment.php b/src/Entity/Attachments/PartAttachment.php index d5c883a0..20974127 100644 --- a/src/Entity/Attachments/PartAttachment.php +++ b/src/Entity/Attachments/PartAttachment.php @@ -44,11 +44,13 @@ namespace App\Entity\Attachments; use App\Entity\Parts\Part; use Doctrine\ORM\Mapping as ORM; +use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; /** * A attachment attached to a part element. * * @ORM\Entity() + * @UniqueEntity({"name", "attachment_type", "element"}) */ class PartAttachment extends Attachment { diff --git a/src/Entity/Attachments/StorelocationAttachment.php b/src/Entity/Attachments/StorelocationAttachment.php index 35213c68..a8a42e6e 100644 --- a/src/Entity/Attachments/StorelocationAttachment.php +++ b/src/Entity/Attachments/StorelocationAttachment.php @@ -44,11 +44,13 @@ namespace App\Entity\Attachments; use App\Entity\Parts\Storelocation; use Doctrine\ORM\Mapping as ORM; +use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; /** * A attachment attached to a measurement unit element. * * @ORM\Entity() + * @UniqueEntity({"name", "attachment_type", "element"}) */ class StorelocationAttachment extends Attachment { diff --git a/src/Entity/Attachments/SupplierAttachment.php b/src/Entity/Attachments/SupplierAttachment.php index 3db739db..a4904211 100644 --- a/src/Entity/Attachments/SupplierAttachment.php +++ b/src/Entity/Attachments/SupplierAttachment.php @@ -44,11 +44,13 @@ namespace App\Entity\Attachments; use App\Entity\Parts\Supplier; use Doctrine\ORM\Mapping as ORM; +use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; /** * A attachment attached to a supplier element. * * @ORM\Entity() + * @UniqueEntity({"name", "attachment_type", "element"}) */ class SupplierAttachment extends Attachment { diff --git a/src/Entity/Attachments/UserAttachment.php b/src/Entity/Attachments/UserAttachment.php index 6198746d..6aeaa638 100644 --- a/src/Entity/Attachments/UserAttachment.php +++ b/src/Entity/Attachments/UserAttachment.php @@ -44,11 +44,13 @@ namespace App\Entity\Attachments; use App\Entity\UserSystem\User; use Doctrine\ORM\Mapping as ORM; +use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; /** * A attachment attached to a user element. * * @ORM\Entity() + * @UniqueEntity({"name", "attachment_type", "element"}) */ class UserAttachment extends Attachment {