mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 14:43:49 +00:00
configure SocialIssue consistency on Activity and AccompanyingPeriod
This commit is contained in:
@@ -17,7 +17,7 @@ use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
|
||||
*/
|
||||
interface AccompanyingPeriodLinkedWithSocialIssuesEntityInterface
|
||||
{
|
||||
public function getAccompanyingPeriod(): AccompanyingPeriod;
|
||||
public function getAccompanyingPeriod(): ?AccompanyingPeriod;
|
||||
|
||||
/**
|
||||
* @return Collection|SocialIssue[]
|
||||
|
@@ -39,14 +39,15 @@ final class AccompanyingPeriodSocialIssueConsistencyEntityListener
|
||||
|
||||
private function ensureConsistencyEntity(AccompanyingPeriodLinkedWithSocialIssuesEntityInterface $entity): void
|
||||
{
|
||||
if (NULL === $period = $entity->getAccompanyingPeriod()) {
|
||||
return;
|
||||
}
|
||||
// remove issues parents on the entity itself
|
||||
$ancestors = SocialIssue::findAncestorSocialIssues($entity->getSocialIssues());
|
||||
foreach ($ancestors as $ancestor) {
|
||||
$entity->removeSocialIssue($ancestor);
|
||||
}
|
||||
|
||||
$period = $entity->getAccompanyingPeriod();
|
||||
|
||||
foreach ($entity->getSocialIssues() as $issue) {
|
||||
// the entity itself test if the social issue is already associated, or not
|
||||
$period->addSocialIssue($issue);
|
||||
|
Reference in New Issue
Block a user