fix validation groups and sequential validator msg

This commit is contained in:
2021-06-14 16:39:27 +02:00
parent b2c1d75fc5
commit 41617295c1
4 changed files with 32 additions and 7 deletions

View File

@@ -19,6 +19,8 @@ class MembersEditor
private array $persistables = [];
private array $membershipsAffected = [];
public const VALIDATION_GROUP = 'household_memberships';
public function __construct(ValidatorInterface $validator, ?Household $household)
{
$this->validator = $validator;
@@ -41,12 +43,12 @@ class MembersEditor
$this->household->addMember($membership);
if ($position->getShareHousehold()) {
foreach ($person->getHouseholdParticipations() as $participation) {
if (FALSE === $participation->getShareHousehold()) {
foreach ($person->getHouseholdParticipationsShareHousehold() as $participation) {
if ($participation === $membership) {
continue;
}
if ($participation === $membership) {
if ($participation->getStartDate() > $membership->getStartDate()) {
continue;
}
@@ -92,7 +94,13 @@ class MembersEditor
public function validate(): ConstraintViolationListInterface
{
return $this->validator->validate($this->getHousehold(), null, [ "memberships" ]);
$list = $this->validator->validate($this->getHousehold(), null, [ self::VALIDATION_GROUP ]);
foreach ($this->membershipsAffected as $m) {
$list->addAll($this->validator->validate($m, null, [ self::VALIDATION_GROUP ]));
}
return $list;
}
public function getPersistable(): array