mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 22:53:49 +00:00
show members without position in list
This commit is contained in:
@@ -19,15 +19,17 @@ class MembersEditor
|
||||
|
||||
private array $persistables = [];
|
||||
private array $membershipsAffected = [];
|
||||
private array $oldMembershipsHashes = [];
|
||||
|
||||
public const VALIDATION_GROUP = 'household_memberships';
|
||||
public const VALIDATION_GROUP_CREATED = 'household_memberships_created';
|
||||
public const VALIDATION_GROUP_AFFECTED = 'household_memberships';
|
||||
|
||||
public function __construct(ValidatorInterface $validator, ?Household $household)
|
||||
{
|
||||
$this->validator = $validator;
|
||||
$this->household = $household;
|
||||
}
|
||||
|
||||
|
||||
public function addMovement(\DateTimeImmutable $date, Person $person, Position $position, ?bool $holder = false, ?string $comment = null): self
|
||||
{
|
||||
if (NULL === $this->household) {
|
||||
@@ -56,6 +58,7 @@ class MembersEditor
|
||||
if ($participation->getEndDate() === NULL || $participation->getEndDate() > $date) {
|
||||
$participation->setEndDate($date);
|
||||
$this->membershipsAffected[] = $participation;
|
||||
$this->oldMembershipsHashes[] = \spl_object_hash($participation);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -97,13 +100,18 @@ class MembersEditor
|
||||
{
|
||||
if ($this->hasHousehold()) {
|
||||
$list = $this->validator
|
||||
->validate($this->getHousehold(), null, [ self::VALIDATION_GROUP ]);
|
||||
->validate($this->getHousehold(), null, [ self::VALIDATION_GROUP_AFFECTED ]);
|
||||
} else {
|
||||
$list = new ConstraintViolationList();
|
||||
}
|
||||
|
||||
foreach ($this->membershipsAffected as $m) {
|
||||
$list->addAll($this->validator->validate($m, null, [ self::VALIDATION_GROUP ]));
|
||||
if (\in_array(\spl_object_hash($m), $this->oldMembershipsHashes)) {
|
||||
$list->addAll($this->validator->validate($m, null, [ self::VALIDATION_GROUP_AFFECTED ]));
|
||||
} else {
|
||||
$list->addAll($this->validator->validate($m, null, [ self::VALIDATION_GROUP_CREATED,
|
||||
self::VALIDATION_GROUP_AFFECTED ]));
|
||||
}
|
||||
}
|
||||
|
||||
return $list;
|
||||
|
Reference in New Issue
Block a user