mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 05:44:24 +00:00
Review load fixtures for activityType & categories
This commit is contained in:
parent
743d6cd0bf
commit
4553051271
@ -2,27 +2,27 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Chill is a software for social workers
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS,
|
* Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS,
|
||||||
* <http://www.champs-libres.coop>, <info@champs-libres.coop>
|
* <http://www.champs-libres.coop>, <info@champs-libres.coop>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
* License, or (at your option) any later version.
|
* License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU Affero General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Chill\ActivityBundle\DataFixtures\ORM;
|
namespace Chill\ActivityBundle\DataFixtures\ORM;
|
||||||
|
|
||||||
use Doctrine\Common\DataFixtures\AbstractFixture;
|
use Doctrine\Bundle\FixturesBundle\Fixture;
|
||||||
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
|
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
|
||||||
use Doctrine\Persistence\ObjectManager;
|
use Doctrine\Persistence\ObjectManager;
|
||||||
use Chill\ActivityBundle\Entity\ActivityType;
|
use Chill\ActivityBundle\Entity\ActivityType;
|
||||||
@ -32,36 +32,59 @@ use Chill\ActivityBundle\Entity\ActivityType;
|
|||||||
*
|
*
|
||||||
* @author Champs-Libres Coop
|
* @author Champs-Libres Coop
|
||||||
*/
|
*/
|
||||||
class LoadActivityType extends AbstractFixture implements OrderedFixtureInterface
|
class LoadActivityType extends Fixture implements OrderedFixtureInterface
|
||||||
{
|
{
|
||||||
public function getOrder()
|
public function getOrder()
|
||||||
{
|
{
|
||||||
return 16100;
|
return 16100;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static $references = array();
|
public static $references = array();
|
||||||
|
|
||||||
public function load(ObjectManager $manager)
|
public function load(ObjectManager $manager)
|
||||||
{
|
{
|
||||||
$types = [
|
$types = [
|
||||||
[ 'name' =>
|
# Exange
|
||||||
['fr' => 'Appel téléphonique', 'en' => 'Telephone call', 'nl' => 'Telefoon appel']],
|
[
|
||||||
[ 'name' =>
|
'name' =>
|
||||||
['fr' => 'Entretien', 'en' => 'Interview', 'nl' => 'Vraaggesprek']],
|
['fr' => 'Entretien physique avec l\'usager'],
|
||||||
[ 'name' =>
|
'category' => 'exchange' ],
|
||||||
['fr' => 'Inspection', 'en' => 'Inspection', 'nl' => 'Inspectie']]
|
[
|
||||||
|
'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) {
|
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())
|
$activityType = (new ActivityType())
|
||||||
->setName(($t['name']));
|
->setName(($t['name']))
|
||||||
|
->setCategory($this->getReference('activity_type_cat_'.$t['category']))
|
||||||
|
->setSocialIssuesVisible(1)
|
||||||
|
->setSocialActionsVisible(1);
|
||||||
$manager->persist($activityType);
|
$manager->persist($activityType);
|
||||||
$reference = 'activity_type_'.$t['name']['en'];
|
$reference = 'activity_type_'.$t['name']['fr'];
|
||||||
$this->addReference($reference, $activityType);
|
$this->addReference($reference, $activityType);
|
||||||
static::$references[] = $reference;
|
static::$references[] = $reference;
|
||||||
}
|
}
|
||||||
|
|
||||||
$manager->flush();
|
$manager->flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,72 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Chill is a software for social workers
|
||||||
|
*
|
||||||
|
* Copyright (C) 2014-2021, Champs Libres Cooperative SCRLFS,
|
||||||
|
* <http://www.champs-libres.coop>, <info@champs-libres.coop>
|
||||||
|
*
|
||||||
|
* 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user