Explicitly mark our normalizers as cachabel or not

This commit is contained in:
Jan Böhmer 2023-03-13 00:35:31 +01:00
parent b38f49a90e
commit a1f4b35749
4 changed files with 39 additions and 12 deletions

View file

@ -21,12 +21,13 @@
namespace App\Serializer;
use App\Entity\Base\AbstractStructuralDBElement;
use Symfony\Component\Serializer\Normalizer\CacheableSupportsMethodInterface;
use Symfony\Component\Serializer\Normalizer\ContextAwareDenormalizerInterface;
use Symfony\Component\Serializer\Normalizer\ContextAwareNormalizerInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
class StructuralElementNormalizer implements ContextAwareNormalizerInterface
class StructuralElementNormalizer implements NormalizerInterface, CacheableSupportsMethodInterface
{
private NormalizerInterface $normalizer;
@ -35,7 +36,7 @@ class StructuralElementNormalizer implements ContextAwareNormalizerInterface
$this->normalizer = $normalizer;
}
public function supportsNormalization($data, string $format = null, array $context = [])
public function supportsNormalization($data, string $format = null): bool
{
return $data instanceof AbstractStructuralDBElement;
}
@ -57,4 +58,9 @@ class StructuralElementNormalizer implements ContextAwareNormalizerInterface
return $data;
}
public function hasCacheableSupportsMethod(): bool
{
return true;
}
}