* * 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 = [ 'social_result_FSL_acces' => [ 'title' => [ 'fr' => 'FSL - accès cautionnement' ], 'action' => 'social_action_instruire' ], 'social_result_FSL_maintien' => [ 'title' => [ 'fr' => 'FSL maintien - impayés de loyer' ], 'action' => 'social_action_MASP' ], 'social_result_soutien_parental' => [ 'title' => [ 'fr' => 'Soutien parental' ], // 'action' => 'social_action_protection_enfant', (via le goal) 'goal' => 'social_goal_proteger' ], 'social_result_accompagnement_mineur' => [ 'title' => [ '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(); } }