function AbstractObjectNormalizer::getCacheKey
Builds the cache key for the attributes cache.
The key must be different for every option in the context that could change which attributes should be handled.
3 calls to AbstractObjectNormalizer::getCacheKey()
- AbstractObjectNormalizer::createChildContext in vendor/
symfony/ serializer/ Normalizer/ AbstractObjectNormalizer.php - Overwritten to update the cache key for the child.
- AbstractObjectNormalizer::denormalize in vendor/
symfony/ serializer/ Normalizer/ AbstractObjectNormalizer.php - Denormalizes data back into an object of the given class.
- AbstractObjectNormalizer::normalize in vendor/
symfony/ serializer/ Normalizer/ AbstractObjectNormalizer.php - Normalizes data into a set of arrays/scalars.
File
-
vendor/
symfony/ serializer/ Normalizer/ AbstractObjectNormalizer.php, line 1077
Class
- AbstractObjectNormalizer
- Base class for a normalizer dealing with objects.
Namespace
Symfony\Component\Serializer\NormalizerCode
private function getCacheKey(?string $format, array $context) : bool|string {
foreach ($context[self::EXCLUDE_FROM_CACHE_KEY] ?? $this->defaultContext[self::EXCLUDE_FROM_CACHE_KEY] as $key) {
unset($context[$key]);
}
unset($context[self::EXCLUDE_FROM_CACHE_KEY]);
unset($context[self::OBJECT_TO_POPULATE]);
unset($context['cache_key']);
// avoid artificially different keys
try {
return hash('xxh128', $format . serialize([
'context' => $context,
'ignored' => $context[self::IGNORED_ATTRIBUTES] ?? $this->defaultContext[self::IGNORED_ATTRIBUTES],
]));
} catch (\Exception) {
// The context cannot be serialized, skip the cache
return false;
}
}