. */ declare(strict_types=1); namespace App\Entity\Attachments; use App\Entity\UserSystem\User; 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 user element. * @extends Attachment */ #[UniqueEntity(['name', 'attachment_type', 'element'])] #[ORM\Entity] class UserAttachment extends Attachment { final public const ALLOWED_ELEMENT_CLASS = User::class; /** * @var User|null the element this attachment is associated with */ #[ORM\ManyToOne(targetEntity: User::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; }