mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-16 23:34:23 +00:00
45 lines
1.4 KiB
PHP
45 lines
1.4 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Chill is a software for social workers
|
|
*
|
|
* For the full copyright and license information, please view
|
|
* the LICENSE file that was distributed with this source code.
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Chill\PersonBundle\Serializer\Normalizer;
|
|
|
|
use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation;
|
|
use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface;
|
|
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
|
|
|
class AccompanyingPeriodParticipationNormalizer implements NormalizerAwareInterface, NormalizerInterface
|
|
{
|
|
protected ?NormalizerInterface $normalizer = null;
|
|
|
|
public function normalize($participation, ?string $format = null, array $context = [])
|
|
{
|
|
/** @var AccompanyingPeriodParticipation $participation */
|
|
return [
|
|
'id' => $participation->getId(),
|
|
'startDate' => $this->normalizer->normalize($participation->getStartDate(), $format),
|
|
'endDate' => $this->normalizer->normalize($participation->getEndDate(), $format),
|
|
'person' => $this->normalizer->normalize($participation->getPerson(), $format),
|
|
];
|
|
}
|
|
|
|
public function setNormalizer(NormalizerInterface $normalizer)
|
|
{
|
|
$this->normalizer = $normalizer;
|
|
}
|
|
|
|
public function supportsNormalization($data, ?string $format = null): bool
|
|
{
|
|
return false;
|
|
|
|
return $data instanceof AccompanyingPeriodParticipation;
|
|
}
|
|
}
|