Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. AbstractObjectNormalizer.php

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\Normalizer

Code

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;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal