You are here

protected function AbstractNormalizer::isCircularReference in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/serializer/Normalizer/AbstractNormalizer.php \Symfony\Component\Serializer\Normalizer\AbstractNormalizer::isCircularReference()

Detects if the configured circular reference limit is reached.

Parameters

object $object:

array $context:

Return value

bool

Throws

CircularReferenceException

3 calls to AbstractNormalizer::isCircularReference()
GetSetMethodNormalizer::normalize in vendor/symfony/serializer/Normalizer/GetSetMethodNormalizer.php
ObjectNormalizer::normalize in vendor/symfony/serializer/Normalizer/ObjectNormalizer.php
PropertyNormalizer::normalize in vendor/symfony/serializer/Normalizer/PropertyNormalizer.php

File

vendor/symfony/serializer/Normalizer/AbstractNormalizer.php, line 184

Class

AbstractNormalizer
Normalizer implementation.

Namespace

Symfony\Component\Serializer\Normalizer

Code

protected function isCircularReference($object, &$context) {
  $objectHash = spl_object_hash($object);
  if (isset($context['circular_reference_limit'][$objectHash])) {
    if ($context['circular_reference_limit'][$objectHash] >= $this->circularReferenceLimit) {
      unset($context['circular_reference_limit'][$objectHash]);
      return true;
    }
    ++$context['circular_reference_limit'][$objectHash];
  }
  else {
    $context['circular_reference_limit'][$objectHash] = 1;
  }
  return false;
}