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

@ -24,9 +24,11 @@ use App\Entity\Base\AbstractStructuralDBElement;
use App\Form\Type\StructuralEntityType;
use App\Repository\StructuralDBElementRepository;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Serializer\Normalizer\CacheableSupportsMethodInterface;
use Symfony\Component\Serializer\Normalizer\ContextAwareDenormalizerInterface;
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
class StructuralElementFromNameDenormalizer implements ContextAwareDenormalizerInterface
class StructuralElementFromNameDenormalizer implements DenormalizerInterface, CacheableSupportsMethodInterface
{
private EntityManagerInterface $em;
@ -35,7 +37,7 @@ class StructuralElementFromNameDenormalizer implements ContextAwareDenormalizerI
$this->em = $em;
}
public function supportsDenormalization($data, string $type, string $format = null, array $context = [])
public function supportsDenormalization($data, string $type, string $format = null)
{
return is_string($data) && is_subclass_of($type, AbstractStructuralDBElement::class);
}
@ -66,4 +68,10 @@ class StructuralElementFromNameDenormalizer implements ContextAwareDenormalizerI
}
return end($elements);
}
public function hasCacheableSupportsMethod(): bool
{
//Must be false, because we do a is_string check on data in supportsDenormalization
return false;
}
}