diff --git a/src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivityType.php b/src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivityType.php index fa846df68..de3c1d4de 100644 --- a/src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivityType.php +++ b/src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivityType.php @@ -2,27 +2,27 @@ /* * Chill is a software for social workers - * - * Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS, + * + * Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS, * , - * + * * 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\ActivityBundle\DataFixtures\ORM; -use Doctrine\Common\DataFixtures\AbstractFixture; +use Doctrine\Bundle\FixturesBundle\Fixture; use Doctrine\Common\DataFixtures\OrderedFixtureInterface; use Doctrine\Persistence\ObjectManager; use Chill\ActivityBundle\Entity\ActivityType; @@ -32,36 +32,59 @@ use Chill\ActivityBundle\Entity\ActivityType; * * @author Champs-Libres Coop */ -class LoadActivityType extends AbstractFixture implements OrderedFixtureInterface +class LoadActivityType extends Fixture implements OrderedFixtureInterface { public function getOrder() { return 16100; } - + public static $references = array(); public function load(ObjectManager $manager) { $types = [ - [ 'name' => - ['fr' => 'Appel téléphonique', 'en' => 'Telephone call', 'nl' => 'Telefoon appel']], - [ 'name' => - ['fr' => 'Entretien', 'en' => 'Interview', 'nl' => 'Vraaggesprek']], - [ 'name' => - ['fr' => 'Inspection', 'en' => 'Inspection', 'nl' => 'Inspectie']] + # Exange + [ + 'name' => + ['fr' => 'Entretien physique avec l\'usager'], + 'category' => 'exchange' ], + [ + 'name' => + ['fr' => 'Appel téléphonique', 'en' => 'Telephone call', 'nl' => 'Telefoon appel'], + 'category' => 'exchange' ], + [ + 'name' => + ['fr' => 'Courriel', 'en' => 'Email', 'nl' => 'Email'], + 'category' => 'exchange' ], + # Meeting + [ + 'name' => + ['fr' => 'Point technique encadrant'], + 'category' => 'meeting' ], + [ + 'name' => + ['fr' => 'Réunion avec des partenaires'], + 'category' => 'meeting' ], + [ + 'name' => + ['fr' => 'Commission pluridisciplinaire et pluri-institutionnelle'], + 'category' => 'meeting' ], ]; - + foreach ($types as $t) { - print "Creating activity type : " . $t['name']['en'] . "\n"; + print "Creating activity type : " . $t['name']['fr'] . " (cat:". $t['category'] . " \n"; $activityType = (new ActivityType()) - ->setName(($t['name'])); + ->setName(($t['name'])) + ->setCategory($this->getReference('activity_type_cat_'.$t['category'])) + ->setSocialIssuesVisible(1) + ->setSocialActionsVisible(1); $manager->persist($activityType); - $reference = 'activity_type_'.$t['name']['en']; + $reference = 'activity_type_'.$t['name']['fr']; $this->addReference($reference, $activityType); static::$references[] = $reference; } - + $manager->flush(); } } diff --git a/src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivityTypeCategory.php b/src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivityTypeCategory.php new file mode 100644 index 000000000..40e45fcf4 --- /dev/null +++ b/src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivityTypeCategory.php @@ -0,0 +1,72 @@ +, + * + * 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\ActivityBundle\DataFixtures\ORM; + +use Doctrine\Bundle\FixturesBundle\Fixture; +use Doctrine\Common\DataFixtures\OrderedFixtureInterface; +use Doctrine\Persistence\ObjectManager; +use Chill\ActivityBundle\Entity\ActivityTypeCategory; + +/** + * Fixtures for ActivityTypeCategory + * + * @author Champs-Libres Coop + */ +class LoadActivityTypeCategory extends Fixture implements OrderedFixtureInterface +{ + public static $references = array(); + + public function getOrder() + { + return 16050; + } + + public function load(ObjectManager $manager) + { + $categories = [ + [ + 'name' => ['fr' => 'Échange avec usager', 'en' => 'Exchange with user'], + 'ref' => 'exchange', + ], + [ + 'name' => ['fr' => 'Réunion', 'en' => 'Meeting'], + 'ref' => 'meeting', + ], + ]; + + foreach ($categories as $cat) { + print "Creating activity type category : " . $cat['ref'] . "\n"; + + $newCat = (new ActivityTypeCategory()) + ->setName(($cat['name'])); + + $manager->persist($newCat); + $reference = 'activity_type_cat_'.$cat['ref']; + + $this->addReference($reference, $newCat); + static::$references[] = $reference; + } + + $manager->flush(); + } +}