From 09e5cc1545aee73d2491594098ced0463717ee22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Sat, 21 Aug 2021 23:18:55 +0200 Subject: [PATCH 1/2] create api for social issue consistency --- ...dLinkedWithSocialIssuesEntityInterface.php | 28 ++++ ...odSocialIssueConsistencyEntityListener.php | 66 +++++++++ .../AccompanyingPeriodWork.php | 4 +- .../Entity/SocialWork/SocialIssue.php | 53 +++++++ ...cialIssueConsistencyEntityListenerTest.php | 140 ++++++++++++++++++ .../Entity/SocialWork/SocialIssueTest.php | 51 +++++++ 6 files changed, 341 insertions(+), 1 deletion(-) create mode 100644 src/Bundle/ChillPersonBundle/AccompanyingPeriod/SocialIssueConsistency/AccompanyingPeriodLinkedWithSocialIssuesEntityInterface.php create mode 100644 src/Bundle/ChillPersonBundle/AccompanyingPeriod/SocialIssueConsistency/AccompanyingPeriodSocialIssueConsistencyEntityListener.php create mode 100644 src/Bundle/ChillPersonBundle/Tests/AccompanyingPeriod/SocialIssueConsistency/AccompanyingPeriodSocialIssueConsistencyEntityListenerTest.php create mode 100644 src/Bundle/ChillPersonBundle/Tests/Entity/SocialWork/SocialIssueTest.php diff --git a/src/Bundle/ChillPersonBundle/AccompanyingPeriod/SocialIssueConsistency/AccompanyingPeriodLinkedWithSocialIssuesEntityInterface.php b/src/Bundle/ChillPersonBundle/AccompanyingPeriod/SocialIssueConsistency/AccompanyingPeriodLinkedWithSocialIssuesEntityInterface.php new file mode 100644 index 000000000..58f1dc32a --- /dev/null +++ b/src/Bundle/ChillPersonBundle/AccompanyingPeriod/SocialIssueConsistency/AccompanyingPeriodLinkedWithSocialIssuesEntityInterface.php @@ -0,0 +1,28 @@ +ensureConsistencyEntity($entity); + } + + public function preUpdate(AccompanyingPeriodLinkedWithSocialIssuesEntityInterface $entity, LifecycleEventArgs $eventArgs) + { + $this->ensureConsistencyEntity($entity); + } + + public function prePersistAccompanyingPeriod(AccompanyingPeriod $period, LifecycleEventArgs $eventArgs) + { + $this->ensureConsistencyAccompanyingPeriod($period); + } + + public function preUpdateAccompanyingPeriod(AccompanyingPeriod $period, LifecycleEventArgs $eventArgs) + { + $this->ensureConsistencyAccompanyingPeriod($period); + } + + private function ensureConsistencyEntity(AccompanyingPeriodLinkedWithSocialIssuesEntityInterface $entity): void + { + // 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); + } + + $this->ensureConsistencyAccompanyingPeriod($period); + } + + private function ensureConsistencyAccompanyingPeriod(AccompanyingPeriod $period): void + { + $ancestors = SocialIssue::findAncestorSocialIssues($period->getSocialIssues()); + + foreach ($ancestors as $ancestor) { + $period->removeSocialIssue($ancestor); + } + } +} diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWork.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWork.php index b0c60de82..39aaf309b 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWork.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWork.php @@ -2,11 +2,13 @@ namespace Chill\PersonBundle\Entity\AccompanyingPeriod; +use Chill\PersonBundle\AccompanyingPeriod\SocialIssueConsistency\AccompanyingPeriodLinkedWithSocialIssuesEntityInterface; use Chill\PersonBundle\Entity\SocialWork\Result; use Chill\PersonBundle\Entity\SocialWork\SocialAction; use Chill\PersonBundle\Entity\Person; use Chill\MainBundle\Entity\User; use Chill\PersonBundle\Entity\AccompanyingPeriod; +use Chill\PersonBundle\Entity\SocialWork\SocialIssue; use Chill\ThirdPartyBundle\Entity\ThirdParty; use DateTimeInterface; use Doctrine\Common\Collections\ArrayCollection; @@ -470,4 +472,4 @@ use Symfony\Component\Validator\Constraints as Assert; return $this; } -} + } diff --git a/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialIssue.php b/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialIssue.php index ae1c573f5..f9956e57f 100644 --- a/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialIssue.php +++ b/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialIssue.php @@ -233,4 +233,57 @@ class SocialIssue return $recursiveSocialActions; } + + /** + * Recursive method which return true if the current $issue is a descendant + * of the $issue given in parameter. + * + * @param SocialIssue $issue + * @return bool + */ + public function isDescendantOf(SocialIssue $issue): bool + { + if (!$this->hasParent()) { + return false; + } + + if ($this->getParent() === $issue) { + return true; + } + + return $this->getParent()->isDescendantOf($issue); + } + + /** + * In a SocialIssues's collection, find the elements which are an ancestor of + * other elements. + * + * Removing those elements of the Collection (which is not done by this method) + * will ensure that only the most descendent elements are present in the collection, + * (any ancestor of another element are present). + * + * @param Collection|SocialIssue[] $socialIssues + * @return Collection|SocialIssue[] + */ + public static function findAncestorSocialIssues(Collection $socialIssues): Collection + { + $ancestors = new ArrayCollection(); + + foreach ($socialIssues as $candidateChild) { + if ($ancestors->contains($candidateChild)) { + continue; + } + foreach ($socialIssues as $candidateParent) { + if ($ancestors->contains($candidateParent)) { + continue; + } + + if ($candidateChild->isDescendantOf($candidateParent)) { + $ancestors->add($candidateParent); + } + } + } + + return $ancestors; + } } diff --git a/src/Bundle/ChillPersonBundle/Tests/AccompanyingPeriod/SocialIssueConsistency/AccompanyingPeriodSocialIssueConsistencyEntityListenerTest.php b/src/Bundle/ChillPersonBundle/Tests/AccompanyingPeriod/SocialIssueConsistency/AccompanyingPeriodSocialIssueConsistencyEntityListenerTest.php new file mode 100644 index 000000000..a94280dd0 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Tests/AccompanyingPeriod/SocialIssueConsistency/AccompanyingPeriodSocialIssueConsistencyEntityListenerTest.php @@ -0,0 +1,140 @@ +setParent($parent), + $grandChild = (new SocialIssue())->setParent($child), + $grandGrandChild = (new SocialIssue())->setParent($grandChild), + ]; + $period = new AccompanyingPeriod(); + $consistency = new AccompanyingPeriodSocialIssueConsistencyEntityListener(); + + foreach ($arraySocialIssues as $issue) { + $period->addSocialIssue($issue); + } + + $consistency->prePersistAccompanyingPeriod($period, $this->generateLifecycleArgs()); + + $this->assertCount(1, $period->getSocialIssues()); + $this->assertSame($grandGrandChild, $period->getSocialIssues()->first()); + } + + public function testPreUpdate() + { + $socialIssues = new ArrayCollection([ + $parent = new SocialIssue(), + $child = (new SocialIssue())->setParent($parent), + $grandChild = (new SocialIssue())->setParent($child), + $grandGrandChild = (new SocialIssue())->setParent($grandChild), + ]); + $period = (new AccompanyingPeriod())->addSocialIssue($unrelated = new SocialIssue()); + $entity = $this->generateClass($period, $socialIssues); + $consistency = new AccompanyingPeriodSocialIssueConsistencyEntityListener(); + + $consistency->preUpdate($entity, $this->generateLifecycleArgs()); + + $this->assertCount(2, $period->getSocialIssues()); + $this->assertContains($grandGrandChild, $period->getSocialIssues()); + $this->assertContains($unrelated, $period->getSocialIssues()); + + $this->assertCount(1, $entity->getSocialIssues()); + $this->assertContains($grandGrandChild, $entity->getSocialIssues()); + } + + public function testPrePersist() + { + $socialIssues = new ArrayCollection([ + $parent = new SocialIssue(), + $child = (new SocialIssue())->setParent($parent), + $grandChild = (new SocialIssue())->setParent($child), + $grandGrandChild = (new SocialIssue())->setParent($grandChild), + ]); + $period = (new AccompanyingPeriod())->addSocialIssue($unrelated = new SocialIssue()); + $entity = $this->generateClass($period, $socialIssues); + $consistency = new AccompanyingPeriodSocialIssueConsistencyEntityListener(); + + $consistency->prePersist($entity, $this->generateLifecycleArgs()); + + $this->assertCount(2, $period->getSocialIssues()); + $this->assertContains($grandGrandChild, $period->getSocialIssues()); + $this->assertContains($unrelated, $period->getSocialIssues()); + + $this->assertCount(1, $entity->getSocialIssues()); + $this->assertContains($grandGrandChild, $entity->getSocialIssues()); + + } + + public function testPreUpdateAccompanyingPeriod() + { + $arraySocialIssues = [ + $parent = new SocialIssue(), + $child = (new SocialIssue())->setParent($parent), + $grandChild = (new SocialIssue())->setParent($child), + $grandGrandChild = (new SocialIssue())->setParent($grandChild), + ]; + $period = new AccompanyingPeriod(); + $consistency = new AccompanyingPeriodSocialIssueConsistencyEntityListener(); + + foreach ($arraySocialIssues as $issue) { + $period->addSocialIssue($issue); + } + + $consistency->prePersistAccompanyingPeriod($period, $this->generateLifecycleArgs()); + + $this->assertCount(1, $period->getSocialIssues()); + $this->assertSame($grandGrandChild, $period->getSocialIssues()->first()); + } + + protected function generateLifecycleArgs(): LifecycleEventArgs + { + return $this->createMock(LifecycleEventArgs::class); + } + + protected function generateClass(AccompanyingPeriod $period, Collection $socialIssues): AccompanyingPeriodLinkedWithSocialIssuesEntityInterface + { + return new class($period, $socialIssues) implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterface + { + public Collection $socialIssues; + public AccompanyingPeriod $period; + + public function __construct($period, $socialIssues) + { + $this->period = $period; + $this->socialIssues = $socialIssues; + } + + public function getAccompanyingPeriod(): AccompanyingPeriod + { + return $this->period; + } + + public function getSocialIssues(): Collection + { + return $this->socialIssues; + } + + public function removeSocialIssue(SocialIssue $issue): AccompanyingPeriodLinkedWithSocialIssuesEntityInterface + { + $this->socialIssues->removeElement($issue); + + return $this; + } + }; + } +} diff --git a/src/Bundle/ChillPersonBundle/Tests/Entity/SocialWork/SocialIssueTest.php b/src/Bundle/ChillPersonBundle/Tests/Entity/SocialWork/SocialIssueTest.php new file mode 100644 index 000000000..16bff1199 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Tests/Entity/SocialWork/SocialIssueTest.php @@ -0,0 +1,51 @@ +setParent($parent); + $grandChild = (new SocialIssue())->setParent($child); + $grandGrandChild = (new SocialIssue())->setParent($grandChild); + $unrelated = new SocialIssue(); + + $this->assertTrue($grandGrandChild->isDescendantOf($parent)); + $this->assertTrue($grandGrandChild->isDescendantOf($grandChild)); + $this->assertTrue($grandGrandChild->isDescendantOf($child)); + $this->assertFalse($grandGrandChild->isDescendantOf($unrelated)); + + $this->assertTrue($grandChild->isDescendantOf($parent)); + $this->assertTrue($grandChild->isDescendantOf($child)); + $this->assertFalse($grandChild->isDescendantOf($unrelated)); + $this->assertFalse($grandChild->isDescendantOf($grandChild)); + + $this->assertFalse($unrelated->isDescendantOf($parent)); + + $this->assertFalse($child->isDescendantOf($grandChild)); + } + + public function testFindSocialIssuesAncestors() + { + $socialIssues = new ArrayCollection([ + $parent = new SocialIssue(), + $child = (new SocialIssue())->setParent($parent), + $grandChild = (new SocialIssue())->setParent($child), + $grandGrandChild = (new SocialIssue())->setParent($grandChild), + $unrelated = new SocialIssue(), + ]); + + $ancestors = SocialIssue::findAncestorSocialIssues($socialIssues); + + $this->assertCount(3, $ancestors); + $this->assertContains($parent, $ancestors); + $this->assertContains($child, $ancestors); + $this->assertContains($grandChild, $ancestors); + } +} From 075f22e79c15bc787e82f63d33a176b3d0ed3d4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Sun, 22 Aug 2021 00:01:24 +0200 Subject: [PATCH 2/2] configure SocialIssue consistency on Activity and AccompanyingPeriod --- .../ChillActivityExtension.php | 1 + .../ChillActivityBundle/Entity/Activity.php | 11 ++++++----- .../services/accompanyingPeriodConsistency.yaml | 14 ++++++++++++++ ...eriodLinkedWithSocialIssuesEntityInterface.php | 2 +- ...PeriodSocialIssueConsistencyEntityListener.php | 5 +++-- .../DependencyInjection/ChillPersonExtension.php | 1 + .../public/vuejs/AccompanyingCourse/js/i18n.js | 2 +- .../vuejs/AccompanyingCourse/store/index.js | 14 ++++++++++++-- .../config/services/accompanyingPeriod.yaml | 15 +++++++++++++++ 9 files changed, 54 insertions(+), 11 deletions(-) create mode 100644 src/Bundle/ChillActivityBundle/config/services/accompanyingPeriodConsistency.yaml create mode 100644 src/Bundle/ChillPersonBundle/config/services/accompanyingPeriod.yaml diff --git a/src/Bundle/ChillActivityBundle/DependencyInjection/ChillActivityExtension.php b/src/Bundle/ChillActivityBundle/DependencyInjection/ChillActivityExtension.php index 61354c7c8..a6f1d6a8a 100644 --- a/src/Bundle/ChillActivityBundle/DependencyInjection/ChillActivityExtension.php +++ b/src/Bundle/ChillActivityBundle/DependencyInjection/ChillActivityExtension.php @@ -55,6 +55,7 @@ class ChillActivityExtension extends Extension implements PrependExtensionInterf $loader->load('services/controller.yaml'); $loader->load('services/form.yaml'); $loader->load('services/templating.yaml'); + $loader->load('services/accompanyingPeriodConsistency.yaml'); } public function prepend(ContainerBuilder $container) diff --git a/src/Bundle/ChillActivityBundle/Entity/Activity.php b/src/Bundle/ChillActivityBundle/Entity/Activity.php index 549f800a2..e37dcbc73 100644 --- a/src/Bundle/ChillActivityBundle/Entity/Activity.php +++ b/src/Bundle/ChillActivityBundle/Entity/Activity.php @@ -23,6 +23,7 @@ namespace Chill\ActivityBundle\Entity; use Chill\DocStoreBundle\Entity\Document; use Chill\DocStoreBundle\Entity\StoredObject; use Chill\MainBundle\Entity\Embeddable\CommentEmbeddable; +use Chill\PersonBundle\AccompanyingPeriod\SocialIssueConsistency\AccompanyingPeriodLinkedWithSocialIssuesEntityInterface; use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\SocialWork\SocialAction; use Chill\PersonBundle\Entity\SocialWork\SocialIssue; @@ -60,7 +61,7 @@ use Symfony\Component\Serializer\Annotation\DiscriminatorMap; * path="scope") */ -class Activity implements HasCenterInterface, HasScopeInterface +class Activity implements HasCenterInterface, HasScopeInterface, AccompanyingPeriodLinkedWithSocialIssuesEntityInterface { const SENTRECEIVED_SENT = 'sent'; const SENTRECEIVED_RECEIVED = 'received'; @@ -417,7 +418,7 @@ class Activity implements HasCenterInterface, HasScopeInterface return $this->persons; } - public function getPersonsAssociated(): array + public function getPersonsAssociated(): array { if (null !== $this->accompanyingPeriod) { $personsAssociated = []; @@ -426,11 +427,11 @@ class Activity implements HasCenterInterface, HasScopeInterface $personsAssociated[] = $participation->getPerson(); } } - return $personsAssociated; + return $personsAssociated; } return []; } - + public function getPersonsNotAssociated(): array { if (null !== $this->accompanyingPeriod) { @@ -443,7 +444,7 @@ class Activity implements HasCenterInterface, HasScopeInterface return $personsNotAssociated; } return []; - } + } public function setPersons(?Collection $persons): self { diff --git a/src/Bundle/ChillActivityBundle/config/services/accompanyingPeriodConsistency.yaml b/src/Bundle/ChillActivityBundle/config/services/accompanyingPeriodConsistency.yaml new file mode 100644 index 000000000..580c64b1c --- /dev/null +++ b/src/Bundle/ChillActivityBundle/config/services/accompanyingPeriodConsistency.yaml @@ -0,0 +1,14 @@ +services: + accompanying_period_social_issue_consistency_for_activity: + class: 'Chill\PersonBundle\AccompanyingPeriod\SocialIssueConsistency\AccompanyingPeriodSocialIssueConsistencyEntityListener' + tags: + - + name: 'doctrine.orm.entity_listener' + event: 'prePersist' + entity: 'Chill\ActivityBundle\Entity\Activity' + lazy: true + - + name: 'doctrine.orm.entity_listener' + event: 'preUpdate' + entity: 'Chill\ActivityBundle\Entity\Activity' + lazy: true diff --git a/src/Bundle/ChillPersonBundle/AccompanyingPeriod/SocialIssueConsistency/AccompanyingPeriodLinkedWithSocialIssuesEntityInterface.php b/src/Bundle/ChillPersonBundle/AccompanyingPeriod/SocialIssueConsistency/AccompanyingPeriodLinkedWithSocialIssuesEntityInterface.php index 58f1dc32a..0f1922435 100644 --- a/src/Bundle/ChillPersonBundle/AccompanyingPeriod/SocialIssueConsistency/AccompanyingPeriodLinkedWithSocialIssuesEntityInterface.php +++ b/src/Bundle/ChillPersonBundle/AccompanyingPeriod/SocialIssueConsistency/AccompanyingPeriodLinkedWithSocialIssuesEntityInterface.php @@ -17,7 +17,7 @@ use Chill\PersonBundle\Entity\SocialWork\SocialIssue; */ interface AccompanyingPeriodLinkedWithSocialIssuesEntityInterface { - public function getAccompanyingPeriod(): AccompanyingPeriod; + public function getAccompanyingPeriod(): ?AccompanyingPeriod; /** * @return Collection|SocialIssue[] diff --git a/src/Bundle/ChillPersonBundle/AccompanyingPeriod/SocialIssueConsistency/AccompanyingPeriodSocialIssueConsistencyEntityListener.php b/src/Bundle/ChillPersonBundle/AccompanyingPeriod/SocialIssueConsistency/AccompanyingPeriodSocialIssueConsistencyEntityListener.php index cb4f594ca..847331180 100644 --- a/src/Bundle/ChillPersonBundle/AccompanyingPeriod/SocialIssueConsistency/AccompanyingPeriodSocialIssueConsistencyEntityListener.php +++ b/src/Bundle/ChillPersonBundle/AccompanyingPeriod/SocialIssueConsistency/AccompanyingPeriodSocialIssueConsistencyEntityListener.php @@ -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); diff --git a/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php b/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php index 9cc026909..07d5dc88f 100644 --- a/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php +++ b/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php @@ -74,6 +74,7 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac $loader->load('services/alt_names.yaml'); $loader->load('services/household.yaml'); $loader->load('services/notification.yaml'); + $loader->load('services/accompanyingPeriod.yaml'); // We can get rid of this file when the service 'chill.person.repository.person' is no more used. // We should use the PersonRepository service instead of a custom service name. $loader->load('services/repository.yaml'); diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/js/i18n.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/js/i18n.js index 3322dd732..d6954c3d4 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/js/i18n.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/js/i18n.js @@ -71,7 +71,7 @@ const appMessages = { edit_temporary_address: "Modifier l'adresse temporaire", assign_course_address: "Désigner comme l'adresse du parcours", remove_button: "Enlever l'adresse", - temporary_address_must_be_changed: "Cette addresse est temporaire et devrait être remplacée par celle d'un usager de référence.", + temporary_address_must_be_changed: "Cette adresse est temporaire et devrait être remplacée par celle d'un usager de référence.", sure: "Êtes-vous sûr ?", sure_description: "Voulez-vous faire de cette adresse l'adresse du parcours ?", ok: "Désigner comme adresse du parcours", diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/store/index.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/store/index.js index b5d1658ca..34a6786fc 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/store/index.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/store/index.js @@ -105,8 +105,13 @@ let initPromise = getAccompanyingCourse(id) state.accompanyingCourse.initialComment = comment; }, updateSocialIssues(state, value) { + console.log('updateSocialIssues', value); state.accompanyingCourse.socialIssues = value; }, + refreshSocialIssues(state, issues) { + console.log('refreshSocialIssues', issues); + state.accompanyingCourse.socialIssues = issues; + }, updateOrigin(state, value) { //console.log('value', value); state.accompanyingCourse.origin = value; @@ -226,14 +231,19 @@ let initPromise = getAccompanyingCourse(id) resolve(); })).catch((error) => { commit('catchError', error) }); }, - updateSocialIssues({ commit }, { payload, body, method }) { + updateSocialIssues({ state, commit }, { payload, body, method }) { //console.log('## action: payload', { payload, body, method }); postSocialIssue(id, body, method) .then(response => new Promise((resolve, reject) => { //console.log('response', response); commit('updateSocialIssues', payload); resolve(); - })).catch((error) => { commit('catchError', error) }); + })).then(() => { + return getAccompanyingCourse(state.accompanyingCourse.id); + }).then(accompanying_course => { + commit('refreshSocialIssues', accompanying_course.socialIssues); + }) + .catch((error) => { commit('catchError', error) }); }, updateOrigin({ commit }, payload) { patchAccompanyingCourse(id, { type: "accompanying_period", origin: { id: payload.id, type: payload.type } }) diff --git a/src/Bundle/ChillPersonBundle/config/services/accompanyingPeriod.yaml b/src/Bundle/ChillPersonBundle/config/services/accompanyingPeriod.yaml new file mode 100644 index 000000000..88e70c9a8 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/config/services/accompanyingPeriod.yaml @@ -0,0 +1,15 @@ +services: + Chill\PersonBundle\AccompanyingPeriod\SocialIssueConsistency\AccompanyingPeriodSocialIssueConsistencyEntityListener: + tags: + - + name: 'doctrine.orm.entity_listener' + event: 'prePersist' + entity: 'Chill\PersonBundle\Entity\AccompanyingPeriod' + lazy: true + method: prePersistAccompanyingPeriod + - + name: 'doctrine.orm.entity_listener' + event: 'preUpdate' + entity: 'Chill\PersonBundle\Entity\AccompanyingPeriod' + lazy: true + method: preUpdateAccompanyingPeriod