From 60aeb57c45d6d2e923fad9288d1a76c2730d7847 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 25 May 2023 12:43:09 +0200 Subject: [PATCH 1/3] FIX [filiation] change validator to allow delete and patch of relationship --- .../Relationship/RelationshipNoDuplicateValidator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Bundle/ChillPersonBundle/Validator/Constraints/Relationship/RelationshipNoDuplicateValidator.php b/src/Bundle/ChillPersonBundle/Validator/Constraints/Relationship/RelationshipNoDuplicateValidator.php index 10e651b56..cb1e5395e 100644 --- a/src/Bundle/ChillPersonBundle/Validator/Constraints/Relationship/RelationshipNoDuplicateValidator.php +++ b/src/Bundle/ChillPersonBundle/Validator/Constraints/Relationship/RelationshipNoDuplicateValidator.php @@ -46,7 +46,7 @@ class RelationshipNoDuplicateValidator extends ConstraintValidator ]); foreach ($relationships as $r) { - if ( + if ( spl_object_hash($r) !== spl_object_hash($value) and $r->getFromPerson() === $fromPerson || $r->getFromPerson() === $toPerson || $r->getToPerson() === $fromPerson From 72f5b0b275b7fd4528fabe70eb516729c165c156 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 25 May 2023 12:52:23 +0200 Subject: [PATCH 2/3] DX [cs-fix] --- .../Relationship/RelationshipNoDuplicateValidator.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Validator/Constraints/Relationship/RelationshipNoDuplicateValidator.php b/src/Bundle/ChillPersonBundle/Validator/Constraints/Relationship/RelationshipNoDuplicateValidator.php index cb1e5395e..b44a966cc 100644 --- a/src/Bundle/ChillPersonBundle/Validator/Constraints/Relationship/RelationshipNoDuplicateValidator.php +++ b/src/Bundle/ChillPersonBundle/Validator/Constraints/Relationship/RelationshipNoDuplicateValidator.php @@ -46,8 +46,8 @@ class RelationshipNoDuplicateValidator extends ConstraintValidator ]); foreach ($relationships as $r) { - if ( spl_object_hash($r) !== spl_object_hash($value) and - $r->getFromPerson() === $fromPerson + if (spl_object_hash($r) !== spl_object_hash($value) + and $r->getFromPerson() === $fromPerson || $r->getFromPerson() === $toPerson || $r->getToPerson() === $fromPerson || $r->getToPerson() === $toPerson From c8bab1218f04e58f3eb20c19ef9a4e61e9f6c88c Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Mon, 5 Jun 2023 10:01:35 +0200 Subject: [PATCH 3/3] FIX [filiation][validator] adjust validation condition --- .../Relationship/RelationshipNoDuplicateValidator.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Validator/Constraints/Relationship/RelationshipNoDuplicateValidator.php b/src/Bundle/ChillPersonBundle/Validator/Constraints/Relationship/RelationshipNoDuplicateValidator.php index b44a966cc..5b1038287 100644 --- a/src/Bundle/ChillPersonBundle/Validator/Constraints/Relationship/RelationshipNoDuplicateValidator.php +++ b/src/Bundle/ChillPersonBundle/Validator/Constraints/Relationship/RelationshipNoDuplicateValidator.php @@ -47,10 +47,12 @@ class RelationshipNoDuplicateValidator extends ConstraintValidator foreach ($relationships as $r) { if (spl_object_hash($r) !== spl_object_hash($value) - and $r->getFromPerson() === $fromPerson - || $r->getFromPerson() === $toPerson - || $r->getToPerson() === $fromPerson - || $r->getToPerson() === $toPerson + and + ( + ($r->getFromPerson() === $fromPerson and $r->getToPerson() === $toPerson) + || + ($r->getFromPerson() === $toPerson and $r->getToPerson() === $fromPerson) + ) ) { $this->context->buildViolation($constraint->message) ->addViolation();