mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-05 07:19:49 +00:00
allow the deletion of a relationship
This commit is contained in:
parent
85796c2271
commit
88961e3e7e
@ -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();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user