From eda454cb9d167d7be85566bc804307a5d4dc7b78 Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Tue, 11 May 2021 18:22:41 +0200 Subject: [PATCH 1/2] Add fixtures for social work --- .../DataFixtures/ORM/LoadSocialActions.php | 82 ++++++++++++++++ .../DataFixtures/ORM/LoadSocialGoals.php | 70 ++++++++++++++ .../DataFixtures/ORM/LoadSocialIssues.php | 90 ++++++++++++++++++ .../DataFixtures/ORM/LoadSocialResults.php | 94 +++++++++++++++++++ 4 files changed, 336 insertions(+) create mode 100644 src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadSocialActions.php create mode 100644 src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadSocialGoals.php create mode 100644 src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadSocialIssues.php create mode 100644 src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadSocialResults.php diff --git a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadSocialActions.php b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadSocialActions.php new file mode 100644 index 000000000..575f7b008 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadSocialActions.php @@ -0,0 +1,82 @@ + + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +namespace Chill\PersonBundle\DataFixtures\ORM; + +use Doctrine\Common\DataFixtures\AbstractFixture; +use Doctrine\Common\DataFixtures\OrderedFixtureInterface; +use Doctrine\Persistence\ObjectManager; + +use Chill\PersonBundle\Entity\SocialWork\SocialAction; + +/** + * Create social actions + * + */ +class LoadSocialActions extends AbstractFixture implements OrderedFixtureInterface +{ + public function getOrder() + { + return 10020; + } + + public static $socialActions = array( + 'social_action_info_conseil' => array( + 'title' => array( + 'fr' => 'Informer, conseiller' + ), + 'issue' => 'social_issue_prev_prot' + ), + 'social_action_instruire' => array( + 'title' => array( + 'fr' => 'Instruire l\'imprime unique pour des impayés' + ), + 'issue' => 'social_issue_prev_prot' + ), + 'social_action_MASP' => array( + 'title' => array( + 'fr' => 'MASP' + ), + 'issue' => 'social_issue_diff_fin' + ), + 'social_action_protection_enfant' => array( + 'title' => array( + 'fr' => 'Protection Enfant confié dans le cadre judiciaire' + ), + 'issue' => 'social_issue_enfant_protection' + ), + ); + + public function load(ObjectManager $manager) + { + foreach (static::$socialActions as $ref => $new) { + $socialAction = new SocialAction(); + $socialAction->setTitle($new['title']); + $socialAction->setIssue($this->getReference($new['issue'])); + $socialAction->setDefaultNotificationDelay(new \DateInterval('PT30M')); + + $manager->persist($socialAction); + $this->addReference($ref, $socialAction); + print("Adding SocialAction '".$new['title']['fr']."'\n"); + } + + $manager->flush(); + } +} diff --git a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadSocialGoals.php b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadSocialGoals.php new file mode 100644 index 000000000..f71d6cf3a --- /dev/null +++ b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadSocialGoals.php @@ -0,0 +1,70 @@ + + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +namespace Chill\PersonBundle\DataFixtures\ORM; + +use Doctrine\Common\DataFixtures\AbstractFixture; +use Doctrine\Common\DataFixtures\OrderedFixtureInterface; +use Doctrine\Persistence\ObjectManager; + +use Chill\PersonBundle\Entity\SocialWork\Goal; + + +/** + * Create social goals + * + */ +class LoadSocialGoals extends AbstractFixture implements OrderedFixtureInterface +{ + public function getOrder() + { + return 10030; + } + + public static $socialGoals = array( + 'social_goal_instuire_dossier' => array( + 'title' => array( + 'fr' => 'Instruire le dossier de surendettement' + ), + 'action' => 'social_action_MASP' + ), + 'social_goal_proteger' => array( + 'title' => array( + 'fr' => 'Protéger via une assistance educative placement' + ), + 'action' => 'social_action_protection_enfant' + ), + ); + + public function load(ObjectManager $manager) + { + foreach (static::$socialGoals as $ref => $new) { + $socialGoal = new Goal(); + $socialGoal->setTitle($new['title']); + $socialGoal->addSocialAction($this->getReference($new['action'])); + + $manager->persist($socialGoal); + $this->addReference($ref, $socialGoal); + print("Adding SocialGoal '".$new['title']['fr']."'\n"); + } + + $manager->flush(); + } +} diff --git a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadSocialIssues.php b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadSocialIssues.php new file mode 100644 index 000000000..c5b635f5b --- /dev/null +++ b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadSocialIssues.php @@ -0,0 +1,90 @@ + + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +namespace Chill\PersonBundle\DataFixtures\ORM; + +use Doctrine\Common\DataFixtures\AbstractFixture; +use Doctrine\Common\DataFixtures\OrderedFixtureInterface; +use Doctrine\Persistence\ObjectManager; + +use Chill\PersonBundle\Entity\SocialWork\SocialIssue; + +/** + * Create social issues + * + */ +class LoadSocialIssues extends AbstractFixture implements OrderedFixtureInterface +{ + public function getOrder() + { + return 10010; + } + + public static $socialIssues = array( + 'social_issue_diff_fin_or_admin' => array( + 'title' => array( + 'fr' => 'ADULTE - DIFFICULTES FINANCIERES ET/OU ADMINISTRATIVES' + ) + ), + 'social_issue_prev_prot' => array( + 'title' => array( + 'fr' => 'ADULTE PREVENTION/PROTECTION' + ), + 'parent' => 'social_issue_diff_fin_or_admin' + ), + 'social_issue_diff_fin' => array( + 'title' => array( + 'fr' => 'Difficulté financière' + ), + 'parent' => 'social_issue_diff_fin_or_admin' + ), + 'social_issue_enfant_famille' => array( + 'title' => array( + 'fr' => 'Enfant / famille' + ) + ), + 'social_issue_enfant_protection' => array( + 'title' => array( + 'fr' => 'enfant - protection' + ), + 'parent' => 'social_issue_enfant_famille' + ), + ); + + public function load(ObjectManager $manager) + { + foreach (static::$socialIssues as $ref => $new) { + $socialIssue = new SocialIssue(); + $socialIssue->setTitle($new['title']); + + if ( array_key_exists('parent', $new)) { + $parentRef = $new['parent']; + $parent = $this->getReference($parentRef); + $socialIssue->setParent($parent); + } + + $manager->persist($socialIssue); + $this->addReference($ref, $socialIssue); + print("Adding SocialIssue '".$new['title']['fr']."'\n"); + } + + $manager->flush(); + } +} diff --git a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadSocialResults.php b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadSocialResults.php new file mode 100644 index 000000000..33cff5eea --- /dev/null +++ b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadSocialResults.php @@ -0,0 +1,94 @@ + + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +namespace Chill\PersonBundle\DataFixtures\ORM; + +use Doctrine\Common\DataFixtures\AbstractFixture; +use Doctrine\Common\DataFixtures\OrderedFixtureInterface; +use Doctrine\Persistence\ObjectManager; + +use Chill\PersonBundle\Entity\SocialWork\Result; + + +/** + * Create social results + * + */ +class LoadSocialResults extends AbstractFixture implements OrderedFixtureInterface +{ + public function getOrder() + { + return 10040; + } + + public static $socialResults = array( + 'social_result_FSL_acces' => array( + 'title' => array( + 'fr' => 'FSL - accès cautionnement' + ), + 'action' => 'social_action_instruire' + ), + 'social_result_FSL_maintien' => array( + 'title' => array( + 'fr' => 'FSL maintien - impayés de loyer' + ), + 'action' => 'social_action_MASP' + ), + 'social_result_soutien_parental' => array( + 'title' => array( + 'fr' => 'Soutien parental' + ), + // 'action' => 'social_action_protection_enfant', (via le goal) + 'goal' => 'social_goal_proteger' + ), + 'social_result_accompagnement_mineur' => array( + 'title' => array( + 'fr' => 'Accompagnement du mineur' + ), + // 'action' => 'social_action_protection_enfant', (via le goal) + 'goal' => 'social_goal_proteger', + ), + ); + + public function load(ObjectManager $manager) + { + foreach (static::$socialResults as $ref => $new) { + $socialResult = new Result(); + $socialResult->setTitle($new['title']); + + if ( array_key_exists('action', $new)) { + $action = $this->getReference($new['action']); + $socialResult->addSocialAction($action); + } + + if ( array_key_exists('goal', $new)) { + $goal = $this->getReference($new['goal']); + $socialResult->addGoal($goal); + } + + + $manager->persist($socialResult); + $this->addReference($ref, $socialResult); + print("Adding SocialResult '".$new['title']['fr']."'\n"); + } + + $manager->flush(); + } +} From 6256d6a19ec0c101797358e44142c772c15075f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 17 May 2021 08:23:21 +0000 Subject: [PATCH 2/2] Apply 1 suggestion(s) to 1 file(s) --- .../ChillPersonBundle/DataFixtures/ORM/LoadSocialActions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadSocialActions.php b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadSocialActions.php index 575f7b008..c12156fc7 100644 --- a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadSocialActions.php +++ b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadSocialActions.php @@ -70,7 +70,7 @@ class LoadSocialActions extends AbstractFixture implements OrderedFixtureInterfa $socialAction = new SocialAction(); $socialAction->setTitle($new['title']); $socialAction->setIssue($this->getReference($new['issue'])); - $socialAction->setDefaultNotificationDelay(new \DateInterval('PT30M')); + $socialAction->setDefaultNotificationDelay(new \DateInterval('P5D')); $manager->persist($socialAction); $this->addReference($ref, $socialAction);