diff --git a/src/Bundle/ChillPersonBundle/Validator/Constraints/Relationship/RelationshipNoDuplicateValidator.php b/src/Bundle/ChillPersonBundle/Validator/Constraints/Relationship/RelationshipNoDuplicateValidator.php index 9c71f442d..f198b371e 100644 --- a/src/Bundle/ChillPersonBundle/Validator/Constraints/Relationship/RelationshipNoDuplicateValidator.php +++ b/src/Bundle/ChillPersonBundle/Validator/Constraints/Relationship/RelationshipNoDuplicateValidator.php @@ -39,6 +39,7 @@ class RelationshipNoDuplicateValidator extends ConstraintValidator $fromPerson = $value->getFromPerson(); $toPerson = $value->getToPerson(); + $relationType = $value->getRelation(); $relationships = $this->relationshipRepository->findBy([ 'fromPerson' => [$fromPerson, $toPerson], @@ -46,11 +47,11 @@ class RelationshipNoDuplicateValidator extends ConstraintValidator ]); foreach ($relationships as $r) { - if ( - $r->getFromPerson() === $fromPerson + if ($r->getRelation()->getId() !== $relationType->getId() && + ($r->getFromPerson() === $fromPerson || $r->getFromPerson() === $toPerson || $r->getToPerson() === $fromPerson - || $r->getToPerson() === $toPerson + || $r->getToPerson() === $toPerson) ) { $this->context->buildViolation($constraint->message) ->addViolation();