logger->debug('begin validation of a role scope instance'); // if the role scope should have a scope if ( !\in_array($value->getRole(), $this->roleProvider->getRolesWithoutScopes(), true) && null === $value->getScope() ) { $this->context->buildViolation($constraint->messagePresenceRequired) ->setParameter('%role%', $this->translator->trans($value->getRole())) ->addViolation(); $this->logger->debug('the role scope should have a scope, but scope is null. Violation build.'); } elseif // if the scope should be null ( \in_array($value->getRole(), $this->roleProvider->getRolesWithoutScopes(), true) && null !== $value->getScope() ) { $this->context->buildViolation($constraint->messageNullRequired) ->setParameter('%role%', $this->translator->trans($value->getRole())) ->addViolation(); $this->logger->debug('the role scole should not have a scope, but scope is not null. Violation build.'); } // everything is fine ! else { $this->logger->debug('role scope is valid. Validation finished.'); } } }