getResource() instanceof Person ? 'p' : 't').$resource->getResource()->getId(); if (\in_array($id, $resourceList, true)) { $this->context->buildViolation($constraint->message) ->setParameter('{{ name }}', $resource->getResource() instanceof Person ? $this->personRender->renderString($resource->getResource(), []) : $this->thirdpartyRender->renderString($resource->getResource(), [])) ->addViolation(); } $resourceList[] = $id; } } }