mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 22:53:49 +00:00
fix validator for taking ancestors into account
This commit is contained in:
@@ -61,14 +61,17 @@ class AccompanyingPeriodValidityValidator extends ConstraintValidator
|
||||
$socialIssuesByKey[$si->getId()] = $si;
|
||||
}
|
||||
|
||||
$periodIssuesKeys = $period->getSocialIssues()->map(function (SocialIssue $si) { return $si->getId();})
|
||||
->toArray();
|
||||
|
||||
dump($socialIssuesByKey);
|
||||
dump($periodIssuesKeys);
|
||||
$periodIssuesWithAncestors = [];
|
||||
foreach ($period->getSocialIssues() as $si) {
|
||||
/** @var SocialIssue $si */
|
||||
$periodIssuesWithAncestors = array_merge($periodIssuesWithAncestors, \array_map(
|
||||
function (SocialIssue $si) { return $si->getId(); },
|
||||
$si->getAncestors(true))
|
||||
);
|
||||
}
|
||||
|
||||
foreach ($socialIssuesByKey as $key => $si) {
|
||||
if (!in_array($key, $periodIssuesKeys)) {
|
||||
if (!in_array($key, $periodIssuesWithAncestors)) {
|
||||
$this->context
|
||||
->buildViolation(
|
||||
$constraint->messageSocialIssueCannotBeDeleted
|
||||
|
Reference in New Issue
Block a user