1

When I try to inject a Doctrine repository (as ServiceEntityRepository) in a custom Normalizer I have this error Maximum function nesting level of '256' reached, aborting!

My customer normalizer:

class GroupNormalizer implements NormalizerInterface
{
/**
 * @var GroupRepository
 */
private $groupRepository;

public function __construct(GroupRepository $groupRepository)
{
    $this->groupRepository = $groupRepository;
}

public function normalize($object, $format = null, array $context = [])
...

And the repository:

class GroupRepository extends ServiceEntityRepository
{

public function __construct(RegistryInterface $registry)
{
    parent::__construct($registry, Group::class);
}

I am using Symfony 3.4.

Do you have any idea to avoid this error?

Edit

My stack trace enter image description here

qdequippe
  • 1,075
  • 6
  • 15
  • Can you post here the full error stack trace please. – Hieu Le Mar 20 '19 at 10:53
  • 1
    Possible duplicate of [Solution for "Fatal error: Maximum function nesting level of '100' reached, aborting!" in PHP](https://stackoverflow.com/questions/8656089/solution-for-fatal-error-maximum-function-nesting-level-of-100-reached-abor) – Evgeny Ruban Mar 20 '19 at 11:05
  • @HieuLe the full stack error is too long to post here (it's Symfony error page in fact) – qdequippe Mar 20 '19 at 12:48
  • The 2 snippets of code you posted looks allright, there must be an issue somewhere else. For that we would need to have a peak at the stack trace. – romaricdrigon Mar 20 '19 at 14:16
  • I added a screenshot of the beginning of the stack trace – qdequippe Mar 20 '19 at 14:54
  • Can't it be an issue of circular reference ? if it is a custom normalizer, maybe it does not set a limit ? – Yoann MIR Mar 20 '19 at 16:53

0 Answers0