mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-23 15:14:58 +00:00
39 lines
1.2 KiB
PHP
39 lines
1.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
/*
|
|
* 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.
|
|
*/
|
|
|
|
namespace Chill\PersonBundle\PersonIdentifier\Normalizer;
|
|
|
|
use Chill\PersonBundle\PersonIdentifier\PersonIdentifierWorker;
|
|
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
|
|
|
final readonly class PersonIdentifierWorkerNormalizer implements NormalizerInterface
|
|
{
|
|
public function normalize($object, ?string $format = null, array $context = []): array
|
|
{
|
|
if (!$object instanceof PersonIdentifierWorker) {
|
|
throw new \Symfony\Component\Serializer\Exception\UnexpectedValueException();
|
|
}
|
|
|
|
return [
|
|
'type' => 'person_identifier_worker',
|
|
'id' => $object->getDefinition()->getId(),
|
|
'engine' => $object->getDefinition()->getEngine(),
|
|
'label' => $object->getDefinition()->getLabel(),
|
|
'isActive' => $object->getDefinition()->isActive(),
|
|
];
|
|
}
|
|
|
|
public function supportsNormalization($data, ?string $format = null): bool
|
|
{
|
|
return $data instanceof PersonIdentifierWorker;
|
|
}
|
|
}
|