mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-08-18 00:29:22 +02:00
Explicitly mark our normalizers as cachabel or not
This commit is contained in:
parent
b38f49a90e
commit
a1f4b35749
4 changed files with 39 additions and 12 deletions
|
@ -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;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue