This commit is contained in:
2021-12-06 17:27:57 +01:00
parent 25147704ad
commit ebd817f61e
9 changed files with 52 additions and 46 deletions

View File

@@ -12,7 +12,6 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Serializer\Normalizer;
use Chill\PersonBundle\Entity\SocialWork\SocialAction;
use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
use Chill\PersonBundle\Templating\Entity\SocialActionRender;
use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait;
@@ -41,8 +40,8 @@ class SocialActionNormalizer implements NormalizerAwareInterface, NormalizerInte
'desactivationDate' => $this->normalizer->normalize($socialAction->getDesactivationDate()),
'title' => $socialAction->getTitle(),
];
case 'docgen':
case 'docgen':
if (null === $socialAction) {
return ['id' => 0, 'title' => '', 'text' => ''];
}
@@ -52,12 +51,13 @@ class SocialActionNormalizer implements NormalizerAwareInterface, NormalizerInte
'text' => $this->render->renderString($socialAction, []),
'title' => $socialAction->getTitle(),
];
default:
throw new \Symfony\Component\Serializer\Exception\RuntimeException("format not supported");
throw new \Symfony\Component\Serializer\Exception\RuntimeException('format not supported');
}
}
public function supportsNormalization($data, string $format = null, array $context = [])
public function supportsNormalization($data, ?string $format = null, array $context = [])
{
if ($data instanceof SocialAction && 'json' === $format) {
return true;
@@ -68,7 +68,7 @@ class SocialActionNormalizer implements NormalizerAwareInterface, NormalizerInte
return true;
}
if (null === $data && ($context['docgen:expects'] ?? null) === SocialAction::class) {
if (null === $data && SocialAction::class === ($context['docgen:expects'] ?? null)) {
return true;
}
}