mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 14:43:49 +00:00
GET for relationship fixed: associated relation displayed
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\Serializer\Normalizer;
|
||||
|
||||
use Chill\PersonBundle\Entity\Relationships\Relationship;
|
||||
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareTrait;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\ObjectToPopulateTrait;
|
||||
|
||||
class RelationshipNormalizer implements NormalizerInterface, NormalizerAwareInterface
|
||||
{
|
||||
use NormalizerAwareTrait;
|
||||
|
||||
use ObjectToPopulateTrait;
|
||||
|
||||
use DenormalizerAwareTrait;
|
||||
|
||||
public function normalize($relationship, ?string $format = null, array $context = [])
|
||||
{
|
||||
return [
|
||||
'type' => 'relationship',
|
||||
'fromPerson' => $this->normalizer->normalize($relationship->getFromPerson()),
|
||||
'toPerson' => $this->normalizer->normalize($relationship->getToPerson()),
|
||||
'relation' => $this->normalizer->normalize($relationship->getRelation()),
|
||||
'reverse' => $relationship->getReverse()
|
||||
];
|
||||
}
|
||||
|
||||
public function supportsNormalization($data, ?string $format = null)
|
||||
{
|
||||
return $data instanceof Relationship;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user