function AbstractObjectNormalizer::isMaxDepthReached
Is the max depth reached for the given attribute?
Parameters
AttributeMetadataInterface[] $attributesMetadata:
1 call to AbstractObjectNormalizer::isMaxDepthReached()
- 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 1029
Class
- AbstractObjectNormalizer
- Base class for a normalizer dealing with objects.
Namespace
Symfony\Component\Serializer\NormalizerCode
private function isMaxDepthReached(array $attributesMetadata, string $class, string $attribute, array &$context) : bool {
if (!($enableMaxDepth = $context[self::ENABLE_MAX_DEPTH] ?? $this->defaultContext[self::ENABLE_MAX_DEPTH] ?? false) || !isset($attributesMetadata[$attribute]) || null === ($maxDepth = $attributesMetadata[$attribute]?->getMaxDepth())) {
return false;
}
$key = \sprintf(self::DEPTH_KEY_PATTERN, $class, $attribute);
if (!isset($context[$key])) {
$context[$key] = 1;
return false;
}
if ($context[$key] === $maxDepth) {
return true;
}
++$context[$key];
return false;
}