Enforce unique names for attachments (per attachment type and part)

This commit is contained in:
Jan Böhmer 2020-03-30 16:01:00 +02:00
parent 7bda340368
commit 41df76e8e6
12 changed files with 24 additions and 0 deletions

View file

@ -43,11 +43,13 @@ declare(strict_types=1);
namespace App\Entity\Attachments; namespace App\Entity\Attachments;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/** /**
* A attachment attached to an attachmentType element. * A attachment attached to an attachmentType element.
* *
* @ORM\Entity() * @ORM\Entity()
* @UniqueEntity({"name", "attachment_type", "element"})
*/ */
class AttachmentTypeAttachment extends Attachment class AttachmentTypeAttachment extends Attachment
{ {

View file

@ -44,11 +44,13 @@ namespace App\Entity\Attachments;
use App\Entity\Parts\Category; use App\Entity\Parts\Category;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/** /**
* A attachment attached to a category element. * A attachment attached to a category element.
* *
* @ORM\Entity() * @ORM\Entity()
* @UniqueEntity({"name", "attachment_type", "element"})
*/ */
class CategoryAttachment extends Attachment class CategoryAttachment extends Attachment
{ {

View file

@ -44,11 +44,13 @@ namespace App\Entity\Attachments;
use App\Entity\PriceInformations\Currency; use App\Entity\PriceInformations\Currency;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/** /**
* A attachment attached to a currency element. * A attachment attached to a currency element.
* *
* @ORM\Entity() * @ORM\Entity()
* @UniqueEntity({"name", "attachment_type", "element"})
*/ */
class CurrencyAttachment extends Attachment class CurrencyAttachment extends Attachment
{ {

View file

@ -44,11 +44,13 @@ namespace App\Entity\Attachments;
use App\Entity\Devices\Device; use App\Entity\Devices\Device;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/** /**
* A attachment attached to a device element. * A attachment attached to a device element.
* *
* @ORM\Entity() * @ORM\Entity()
* @UniqueEntity({"name", "attachment_type", "element"})
*/ */
class DeviceAttachment extends Attachment class DeviceAttachment extends Attachment
{ {

View file

@ -44,11 +44,13 @@ namespace App\Entity\Attachments;
use App\Entity\Parts\Footprint; use App\Entity\Parts\Footprint;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/** /**
* A attachment attached to a footprint element. * A attachment attached to a footprint element.
* *
* @ORM\Entity() * @ORM\Entity()
* @UniqueEntity({"name", "attachment_type", "element"})
*/ */
class FootprintAttachment extends Attachment class FootprintAttachment extends Attachment
{ {

View file

@ -44,11 +44,13 @@ namespace App\Entity\Attachments;
use App\Entity\UserSystem\Group; use App\Entity\UserSystem\Group;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/** /**
* A attachment attached to a Group element. * A attachment attached to a Group element.
* *
* @ORM\Entity() * @ORM\Entity()
* @UniqueEntity({"name", "attachment_type", "element"})
*/ */
class GroupAttachment extends Attachment class GroupAttachment extends Attachment
{ {

View file

@ -44,11 +44,13 @@ namespace App\Entity\Attachments;
use App\Entity\Parts\Manufacturer; use App\Entity\Parts\Manufacturer;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/** /**
* A attachment attached to a manufacturer element. * A attachment attached to a manufacturer element.
* *
* @ORM\Entity() * @ORM\Entity()
* @UniqueEntity({"name", "attachment_type", "element"})
*/ */
class ManufacturerAttachment extends Attachment class ManufacturerAttachment extends Attachment
{ {

View file

@ -45,11 +45,13 @@ namespace App\Entity\Attachments;
use App\Entity\Parts\Manufacturer; use App\Entity\Parts\Manufacturer;
use App\Entity\Parts\MeasurementUnit; use App\Entity\Parts\MeasurementUnit;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/** /**
* A attachment attached to a measurement unit element. * A attachment attached to a measurement unit element.
* *
* @ORM\Entity() * @ORM\Entity()
* @UniqueEntity({"name", "attachment_type", "element"})
*/ */
class MeasurementUnitAttachment extends Attachment class MeasurementUnitAttachment extends Attachment
{ {

View file

@ -44,11 +44,13 @@ namespace App\Entity\Attachments;
use App\Entity\Parts\Part; use App\Entity\Parts\Part;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/** /**
* A attachment attached to a part element. * A attachment attached to a part element.
* *
* @ORM\Entity() * @ORM\Entity()
* @UniqueEntity({"name", "attachment_type", "element"})
*/ */
class PartAttachment extends Attachment class PartAttachment extends Attachment
{ {

View file

@ -44,11 +44,13 @@ namespace App\Entity\Attachments;
use App\Entity\Parts\Storelocation; use App\Entity\Parts\Storelocation;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/** /**
* A attachment attached to a measurement unit element. * A attachment attached to a measurement unit element.
* *
* @ORM\Entity() * @ORM\Entity()
* @UniqueEntity({"name", "attachment_type", "element"})
*/ */
class StorelocationAttachment extends Attachment class StorelocationAttachment extends Attachment
{ {

View file

@ -44,11 +44,13 @@ namespace App\Entity\Attachments;
use App\Entity\Parts\Supplier; use App\Entity\Parts\Supplier;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/** /**
* A attachment attached to a supplier element. * A attachment attached to a supplier element.
* *
* @ORM\Entity() * @ORM\Entity()
* @UniqueEntity({"name", "attachment_type", "element"})
*/ */
class SupplierAttachment extends Attachment class SupplierAttachment extends Attachment
{ {

View file

@ -44,11 +44,13 @@ namespace App\Entity\Attachments;
use App\Entity\UserSystem\User; use App\Entity\UserSystem\User;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/** /**
* A attachment attached to a user element. * A attachment attached to a user element.
* *
* @ORM\Entity() * @ORM\Entity()
* @UniqueEntity({"name", "attachment_type", "element"})
*/ */
class UserAttachment extends Attachment class UserAttachment extends Attachment
{ {