mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-01-15 22:59:33 +00:00
Implemented basic discriminator map for Attachment API access. Now we can properly create part attachments using a POST operation
This commit is contained in:
parent
fad8f26eaa
commit
16b3d58242
3 changed files with 73 additions and 1 deletions
|
|
@ -23,8 +23,14 @@ declare(strict_types=1);
|
|||
namespace App\Entity\Attachments;
|
||||
|
||||
use App\Entity\Parts\Part;
|
||||
use App\Serializer\OverrideClassDenormalizer;
|
||||
use App\Serializer\TypeOverride\TypeOverridableSerializer;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
||||
use Symfony\Component\PropertyInfo\Type;
|
||||
use Symfony\Component\Serializer\Attribute\Context;
|
||||
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
|
||||
use Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer;
|
||||
|
||||
/**
|
||||
* A attachment attached to a part element.
|
||||
|
|
@ -40,5 +46,7 @@ class PartAttachment extends Attachment
|
|||
*/
|
||||
#[ORM\ManyToOne(targetEntity: Part::class, inversedBy: 'attachments')]
|
||||
#[ORM\JoinColumn(name: 'element_id', nullable: false, onDelete: 'CASCADE')]
|
||||
// Set the correct type for the element property to use
|
||||
#[Context(denormalizationContext: [OverrideClassDenormalizer::CONTEXT_KEY => Part::class])]
|
||||
protected ?AttachmentContainingDBElement $element = null;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue