mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-11-10 06:08:25 +00:00
Add support for serializing identifiers in PersonJsonNormalizer and improve PersonIdentifier entity serialization.
- Extended `PersonJsonNormalizer` to include `identifiers` field normalization. - Added `Serializer` annotations to `PersonIdentifier` and `PersonIdentifierDefinition` for enhanced serialization support. - Updated `PersonIdentifier` and `PersonIdentifierDefinition` to define serialization groups and discriminator maps.
This commit is contained in:
@@ -15,6 +15,7 @@ use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\PersonIdentifier\Validator\UniqueIdentifierConstraint;
|
||||
use Chill\PersonBundle\PersonIdentifier\Validator\ValidIdentifierConstraint;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Annotation as Serializer;
|
||||
|
||||
#[ORM\Entity]
|
||||
#[ORM\Table(name: 'chill_person_identifier')]
|
||||
@@ -22,11 +23,13 @@ use Doctrine\ORM\Mapping as ORM;
|
||||
#[ORM\UniqueConstraint(name: 'chill_person_identifier_unique_person_definition', columns: ['definition_id', 'person_id'])]
|
||||
#[UniqueIdentifierConstraint]
|
||||
#[ValidIdentifierConstraint]
|
||||
#[Serializer\DiscriminatorMap('type', ['person_identifier' => PersonIdentifier::class])]
|
||||
class PersonIdentifier
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\Column(name: 'id', type: \Doctrine\DBAL\Types\Types::INTEGER)]
|
||||
#[ORM\GeneratedValue]
|
||||
#[Serializer\Groups(['read'])]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\ManyToOne(targetEntity: Person::class)]
|
||||
@@ -34,6 +37,7 @@ class PersonIdentifier
|
||||
private ?Person $person = null;
|
||||
|
||||
#[ORM\Column(name: 'value', type: \Doctrine\DBAL\Types\Types::JSON, nullable: false, options: ['default' => '[]', 'jsonb' => true])]
|
||||
#[Serializer\Groups(['read'])]
|
||||
private array $value = [];
|
||||
|
||||
#[ORM\Column(name: 'canonical', type: \Doctrine\DBAL\Types\Types::TEXT, nullable: false, options: ['default' => ''])]
|
||||
@@ -42,6 +46,7 @@ class PersonIdentifier
|
||||
public function __construct(
|
||||
#[ORM\ManyToOne(targetEntity: PersonIdentifierDefinition::class)]
|
||||
#[ORM\JoinColumn(name: 'definition_id', referencedColumnName: 'id', nullable: false, onDelete: 'RESTRICT')]
|
||||
#[Serializer\Groups(['read'])]
|
||||
private PersonIdentifierDefinition $definition,
|
||||
) {}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user