mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 07:03:49 +00:00
first impl for create form
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\PersonBundle\Serializer\Normalizer;
|
||||
|
||||
use Chill\PersonBundle\Entity\SocialWork\SocialAction;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
use Chill\PersonBundle\Templating\Entity\SocialActionRender;
|
||||
|
||||
|
||||
class SocialActionNormalizer implements NormalizerInterface, NormalizerAwareInterface
|
||||
{
|
||||
use NormalizerAwareTrait;
|
||||
|
||||
private SocialActionRender $render;
|
||||
|
||||
public function __construct(SocialActionRender $render)
|
||||
{
|
||||
$this->render = $render;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function normalize($socialAction, string $format = null, array $context = [])
|
||||
{
|
||||
return [
|
||||
'text' => $this->render->renderString($socialAction, []),
|
||||
'parent' => $this->normalizer->normalize($socialAction->getParent()),
|
||||
'desactivationDate' => $this->normalizer->normalize($socialAction->getDesactivationDate()),
|
||||
'title' => $socialAction->getTitle()
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function supportsNormalization($data, string $format = null)
|
||||
{
|
||||
return $data instanceof SocialAction;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user