mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-10-04 20:39:40 +00:00
Add getSupportedTypes method for (de)normalizerInterface implementations
This commit is contained in:
@@ -16,7 +16,6 @@ use Chill\MainBundle\Entity\Address;
|
||||
use Chill\MainBundle\Templating\Entity\AddressRender;
|
||||
use Symfony\Component\Serializer\Exception\UnexpectedValueException;
|
||||
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
|
||||
use Symfony\Component\Serializer\Normalizer\ContextAwareNormalizerInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait;
|
||||
|
||||
@@ -137,4 +136,21 @@ class AddressNormalizer implements \Symfony\Component\Serializer\Normalizer\Norm
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getSupportedTypes(?string $format): array
|
||||
{
|
||||
if ('json' === $format) {
|
||||
return [
|
||||
Address::class => true,
|
||||
];
|
||||
}
|
||||
|
||||
if ('docgen' === $format) {
|
||||
return [
|
||||
Address::class => false,
|
||||
];
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
@@ -69,4 +69,15 @@ class CenterNormalizer implements DenormalizerInterface, NormalizerInterface
|
||||
{
|
||||
return $data instanceof Center && 'json' === $format;
|
||||
}
|
||||
|
||||
public function getSupportedTypes(?string $format): array
|
||||
{
|
||||
if ('json' !== $format && null !== $format) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return [
|
||||
Center::class => true,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@@ -45,4 +45,11 @@ class CollectionNormalizer implements NormalizerAwareInterface, NormalizerInterf
|
||||
{
|
||||
return $data instanceof Collection;
|
||||
}
|
||||
|
||||
public function getSupportedTypes(?string $format): array
|
||||
{
|
||||
return [
|
||||
Collection::class => true,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@@ -82,4 +82,9 @@ class CommentEmbeddableDocGenNormalizer implements \Symfony\Component\Serializer
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getSupportedTypes(?string $format): array
|
||||
{
|
||||
return 'docgen' === $format ? [CommentEmbeddable::class => true] : [];
|
||||
}
|
||||
}
|
||||
|
@@ -121,4 +121,25 @@ class DateNormalizer implements \Symfony\Component\Serializer\Normalizer\Normali
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getSupportedTypes(?string $format): array
|
||||
{
|
||||
if ('json' === $format) {
|
||||
return [
|
||||
\DateTimeInterface::class => true,
|
||||
\DateTime::class => true,
|
||||
\DateTimeImmutable::class => true,
|
||||
];
|
||||
}
|
||||
|
||||
if ('docgen' === $format) {
|
||||
return [
|
||||
\DateTimeInterface::class => true,
|
||||
\DateTime::class => true,
|
||||
\DateTimeImmutable::class => true,
|
||||
];
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
@@ -69,4 +69,11 @@ class DiscriminatedObjectDenormalizer implements \Symfony\Component\Serializer\N
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getSupportedTypes(?string $format): array
|
||||
{
|
||||
return [
|
||||
self::TYPE => true,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@@ -65,4 +65,11 @@ class DoctrineExistingEntityNormalizer implements DenormalizerInterface
|
||||
// we do not have any class discriminator. Check that the id is the only one key
|
||||
return 1 === \count($data);
|
||||
}
|
||||
|
||||
public function getSupportedTypes(?string $format): array
|
||||
{
|
||||
return [
|
||||
'object' => false,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@@ -79,4 +79,9 @@ class EntityWorkflowStepNormalizer implements NormalizerAwareInterface, Normaliz
|
||||
{
|
||||
return $data instanceof EntityWorkflowStep && 'json' === $format;
|
||||
}
|
||||
|
||||
public function getSupportedTypes(?string $format): array
|
||||
{
|
||||
return 'json' === $format ? [EntityWorkflowStep::class => true] : [];
|
||||
}
|
||||
}
|
||||
|
@@ -37,4 +37,11 @@ class GenderDocGenNormalizer implements \Symfony\Component\Serializer\Normalizer
|
||||
'type' => 'chill_main_gender',
|
||||
];
|
||||
}
|
||||
|
||||
public function getSupportedTypes(?string $format): array
|
||||
{
|
||||
return [
|
||||
Gender::class => true,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@@ -55,4 +55,9 @@ class NotificationNormalizer implements NormalizerAwareInterface, NormalizerInte
|
||||
{
|
||||
return $data instanceof Notification && 'json' === $format;
|
||||
}
|
||||
|
||||
public function getSupportedTypes(?string $format): array
|
||||
{
|
||||
return 'json' === $format ? [Notification::class => true] : [];
|
||||
}
|
||||
}
|
||||
|
@@ -78,4 +78,15 @@ class PhonenumberNormalizer implements \Symfony\Component\Serializer\Normalizer\
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getSupportedTypes(?string $format): array
|
||||
{
|
||||
if ('json' === $format || 'docgen' === $format) {
|
||||
return [
|
||||
PhoneNumber::class => true,
|
||||
];
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
@@ -34,4 +34,11 @@ class PointNormalizer implements DenormalizerInterface
|
||||
{
|
||||
return Point::class === $type;
|
||||
}
|
||||
|
||||
public function getSupportedTypes(?string $format): array
|
||||
{
|
||||
return [
|
||||
Point::class => true,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@@ -34,4 +34,15 @@ class UserGroupDenormalizer implements DenormalizerInterface
|
||||
&& 2 === count(array_keys($data))
|
||||
;
|
||||
}
|
||||
|
||||
public function getSupportedTypes(?string $format): array
|
||||
{
|
||||
if ('json' !== $format) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return [
|
||||
UserGroup::class => false,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@@ -122,4 +122,15 @@ class UserNormalizer implements \Symfony\Component\Serializer\Normalizer\Normali
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getSupportedTypes(?string $format): array
|
||||
{
|
||||
if ('json' === $format || 'docgen' === $format) {
|
||||
return [
|
||||
User::class => true,
|
||||
];
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user