Allow to create Attachments for all entity types using the API

This fixes issue #502
This commit is contained in:
Jan Böhmer 2024-03-02 21:39:30 +01:00
parent 16b3d58242
commit ce768764cc
14 changed files with 47 additions and 9 deletions

View file

@ -24,8 +24,10 @@ namespace App\Entity\Attachments;
use App\Entity\Parts\Manufacturer;
use App\Entity\Parts\MeasurementUnit;
use App\Serializer\OverrideClassDenormalizer;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Serializer\Attribute\Context;
/**
* An attachment attached to a measurement unit element.
@ -40,5 +42,6 @@ class MeasurementUnitAttachment extends Attachment
#[ORM\ManyToOne(targetEntity: MeasurementUnit::class, inversedBy: 'attachments')]
#[ORM\JoinColumn(name: 'element_id', nullable: false, onDelete: 'CASCADE')]
#[Context(denormalizationContext: [OverrideClassDenormalizer::CONTEXT_KEY => self::ALLOWED_ELEMENT_CLASS])]
protected ?AttachmentContainingDBElement $element = null;
}