allow the deletion of a relationship

This commit is contained in:
Julie Lenaerts 2022-07-18 12:00:09 +02:00
parent 85796c2271
commit 88961e3e7e

View File

@ -39,6 +39,7 @@ class RelationshipNoDuplicateValidator extends ConstraintValidator
$fromPerson = $value->getFromPerson(); $fromPerson = $value->getFromPerson();
$toPerson = $value->getToPerson(); $toPerson = $value->getToPerson();
$relationType = $value->getRelation();
$relationships = $this->relationshipRepository->findBy([ $relationships = $this->relationshipRepository->findBy([
'fromPerson' => [$fromPerson, $toPerson], 'fromPerson' => [$fromPerson, $toPerson],
@ -46,11 +47,11 @@ class RelationshipNoDuplicateValidator extends ConstraintValidator
]); ]);
foreach ($relationships as $r) { foreach ($relationships as $r) {
if ( if ($r->getRelation()->getId() !== $relationType->getId() &&
$r->getFromPerson() === $fromPerson ($r->getFromPerson() === $fromPerson
|| $r->getFromPerson() === $toPerson || $r->getFromPerson() === $toPerson
|| $r->getToPerson() === $fromPerson || $r->getToPerson() === $fromPerson
|| $r->getToPerson() === $toPerson || $r->getToPerson() === $toPerson)
) { ) {
$this->context->buildViolation($constraint->message) $this->context->buildViolation($constraint->message)
->addViolation(); ->addViolation();