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

@ -42,8 +42,10 @@ declare(strict_types=1);
namespace App\Entity\Attachments;
use App\Entity\LabelSystem\LabelProfile;
use App\Serializer\OverrideClassDenormalizer;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Serializer\Attribute\Context;
/**
* A attachment attached to a user element.
@ -60,5 +62,6 @@ class LabelAttachment extends Attachment
*/
#[ORM\ManyToOne(targetEntity: LabelProfile::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;
}