mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 22:53:49 +00:00
check for ancestors when validating the presence of accompanying
period's social issues
This commit is contained in:
@@ -11,7 +11,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\Validator\Constraints\AccompanyingPeriod;
|
||||
|
||||
use Chill\ActivityBundle\Repository\ActivityACLAwareRepository;
|
||||
use Chill\ActivityBundle\Repository\ActivityRepository;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
|
||||
@@ -57,21 +56,26 @@ class AccompanyingPeriodValidityValidator extends ConstraintValidator
|
||||
}
|
||||
|
||||
$socialIssuesByKey = [];
|
||||
|
||||
foreach ($socialIssues as $si) {
|
||||
$socialIssuesByKey[$si->getId()] = $si;
|
||||
}
|
||||
|
||||
$periodIssuesWithAncestors = [];
|
||||
|
||||
foreach ($period->getSocialIssues() as $si) {
|
||||
/** @var SocialIssue $si */
|
||||
$periodIssuesWithAncestors = array_merge($periodIssuesWithAncestors, \array_map(
|
||||
function (SocialIssue $si) { return $si->getId(); },
|
||||
$si->getAncestors(true))
|
||||
$periodIssuesWithAncestors = array_merge(
|
||||
$periodIssuesWithAncestors,
|
||||
array_map(
|
||||
static function (SocialIssue $si) { return $si->getId(); },
|
||||
$si->getAncestors(true)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
foreach ($socialIssuesByKey as $key => $si) {
|
||||
if (!in_array($key, $periodIssuesWithAncestors)) {
|
||||
if (!in_array($key, $periodIssuesWithAncestors, true)) {
|
||||
$this->context
|
||||
->buildViolation(
|
||||
$constraint->messageSocialIssueCannotBeDeleted
|
||||
|
Reference in New Issue
Block a user