Skip to content

Commit c3c380e

Browse files
authored
Merge pull request #1387 from soyuka/fix/cache-denormalization
In memory cache for supportsDenormalization types
2 parents 3e08f29 + 7d6352f commit c3c380e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/Serializer/AbstractItemNormalizer.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ abstract class AbstractItemNormalizer extends AbstractObjectNormalizer
4343
protected $iriConverter;
4444
protected $resourceClassResolver;
4545
protected $propertyAccessor;
46+
protected $localCache = [];
4647

4748
public function __construct(PropertyNameCollectionFactoryInterface $propertyNameCollectionFactory, PropertyMetadataFactoryInterface $propertyMetadataFactory, IriConverterInterface $iriConverter, ResourceClassResolverInterface $resourceClassResolver, PropertyAccessorInterface $propertyAccessor = null, NameConverterInterface $nameConverter = null, ClassMetadataFactoryInterface $classMetadataFactory = null)
4849
{
@@ -99,7 +100,7 @@ public function normalize($object, $format = null, array $context = [])
99100
*/
100101
public function supportsDenormalization($data, $type, $format = null)
101102
{
102-
return $this->resourceClassResolver->isResourceClass($type);
103+
return $this->localCache[$type] ?? $this->localCache[$type] = $this->resourceClassResolver->isResourceClass($type);
103104
}
104105

105106
/**

0 commit comments

Comments
 (0)