first impl for create form

This commit is contained in:
2021-06-18 19:41:58 +02:00
parent 07cc394abd
commit 3abfdbf6fd
16 changed files with 448 additions and 8 deletions

View File

@@ -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;
}
}