mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 05:44:24 +00:00
fixtures accompanyingPeriod + fixture new firstnames set
This commit is contained in:
parent
ea4e3c715e
commit
365a398743
@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
namespace Chill\PersonBundle\DataFixtures\ORM;
|
namespace Chill\PersonBundle\DataFixtures\ORM;
|
||||||
|
|
||||||
|
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||||
use Doctrine\Common\DataFixtures\AbstractFixture;
|
use Doctrine\Common\DataFixtures\AbstractFixture;
|
||||||
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
|
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
|
||||||
use Doctrine\Persistence\ObjectManager;
|
use Doctrine\Persistence\ObjectManager;
|
||||||
@ -195,6 +196,9 @@ class LoadPeople extends AbstractFixture implements OrderedFixtureInterface, Con
|
|||||||
case 'maritalStatus':
|
case 'maritalStatus':
|
||||||
$value = $this->getReference($value);
|
$value = $this->getReference($value);
|
||||||
break;
|
break;
|
||||||
|
case 'accompanyingPeriods':
|
||||||
|
$this->addAccompanyingPeriods($p, $value, $manager);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
//try to add the data using the setSomething function,
|
//try to add the data using the setSomething function,
|
||||||
@ -230,15 +234,15 @@ class LoadPeople extends AbstractFixture implements OrderedFixtureInterface, Con
|
|||||||
private function getRandomAddress()
|
private function getRandomAddress()
|
||||||
{
|
{
|
||||||
return (new Address())
|
return (new Address())
|
||||||
->setStreetAddress1($this->faker->streetAddress)
|
->setStreetAddress1($this->faker->streetAddress)
|
||||||
->setStreetAddress2(
|
->setStreetAddress2(
|
||||||
rand(0,9) > 5 ? $this->faker->streetAddress : ''
|
rand(0,9) > 5 ? $this->faker->streetAddress : ''
|
||||||
)
|
)
|
||||||
->setPostcode($this->getReference(
|
->setPostcode($this->getReference(
|
||||||
LoadPostalCodes::$refs[array_rand(LoadPostalCodes::$refs)]
|
LoadPostalCodes::$refs[array_rand(LoadPostalCodes::$refs)]
|
||||||
))
|
))
|
||||||
->setValidFrom($this->faker->dateTimeBetween('-5 years'))
|
->setValidFrom($this->faker->dateTimeBetween('-5 years'))
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getCountry($countryCode)
|
private function getCountry($countryCode)
|
||||||
@ -251,25 +255,25 @@ class LoadPeople extends AbstractFixture implements OrderedFixtureInterface, Con
|
|||||||
->findOneByCountryCode($countryCode);
|
->findOneByCountryCode($countryCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
private $maritalStatusRef = ['ms_single', 'ms_married', 'ms_widow', 'ms_separat',
|
private $maritalStatusRef = ['ms_single', 'ms_married', 'ms_widow', 'ms_separat',
|
||||||
'ms_divorce', 'ms_legalco', 'ms_unknown'];
|
'ms_divorce', 'ms_legalco', 'ms_unknown'];
|
||||||
|
|
||||||
private $firstNamesMale = array("Jean", "Mohamed", "Alfred", "Robert",
|
private $firstNamesMale = array("Jean", "Mohamed", "Alfred", "Robert", "Justin", "Brian",
|
||||||
"Compère", "Jean-de-Dieu",
|
"Compère", "Jean-de-Dieu", "Charles", "Pierre", "Luc", "Mathieu", "Alain", "Etienne", "Eric",
|
||||||
"Charles", "Pierre", "Luc", "Mathieu", "Alain", "Etienne", "Eric",
|
"Corentin", "Gaston", "Spirou", "Fantasio", "Mahmadou", "Mohamidou", "Vursuv", "Youssef" );
|
||||||
"Corentin", "Gaston", "Spirou", "Fantasio", "Mahmadou", "Mohamidou",
|
|
||||||
"Vursuv" );
|
private $firstNamesFemale = array("Svedana", "Sevlatina", "Irène", "Marcelle",
|
||||||
private $firstNamesFemale = array("Svedana", "Sevlatina","Irène", "Marcelle",
|
"Corentine", "Alfonsine", "Caroline", "Solange", "Gostine", "Fatoumata", "Nicole",
|
||||||
"Corentine", "Alfonsine","Caroline","Solange","Gostine", "Fatoumata",
|
"Groseille", "Chana", "Oxana", "Ivana", "Julie", "Tina", "Adèle" );
|
||||||
"Groseille", "Chana", "Oxana", "Ivana");
|
|
||||||
|
private $lastNames = array("Diallo", "Bah", "Gaillot", "Martin");
|
||||||
|
|
||||||
private $lastNames = array("Diallo", "Bah", "Gaillot");
|
|
||||||
private $lastNamesTrigrams = array("fas", "tré", "hu", 'blart', 'van', 'der', 'lin', 'den',
|
private $lastNamesTrigrams = array("fas", "tré", "hu", 'blart', 'van', 'der', 'lin', 'den',
|
||||||
'ta', 'mi', 'gna', 'bol', 'sac', 'ré', 'jo', 'du', 'pont', 'cas', 'tor', 'rob', 'al',
|
'ta', 'mi', 'net', 'gna', 'bol', 'sac', 'ré', 'jo', 'du', 'pont', 'cas', 'tor', 'rob', 'al',
|
||||||
'ma', 'gone', 'car',"fu", "ka", "lot", "no", "va", "du", "bu", "su",
|
'ma', 'gone', 'car',"fu", "ka", "lot", "no", "va", "du", "bu", "su", "jau", "tte", 'sir',
|
||||||
"lo", 'to', "cho", "car", 'mo','zu', 'qi', 'mu');
|
"lo", 'to', "cho", "car", 'mo','zu', 'qi', 'mu');
|
||||||
|
|
||||||
private $genders = array(Person::MALE_GENDER, Person::FEMALE_GENDER);
|
private $genders = array(Person::MALE_GENDER, Person::FEMALE_GENDER);
|
||||||
|
|
||||||
private $years = array();
|
private $years = array();
|
||||||
|
|
||||||
@ -287,7 +291,22 @@ class LoadPeople extends AbstractFixture implements OrderedFixtureInterface, Con
|
|||||||
'CountryOfBirth' => 'FR',
|
'CountryOfBirth' => 'FR',
|
||||||
'Nationality' => 'RU',
|
'Nationality' => 'RU',
|
||||||
'center' => 'centerA',
|
'center' => 'centerA',
|
||||||
'maritalStatus' => 'ms_divorce'
|
'maritalStatus' => 'ms_divorce',
|
||||||
|
'accompanyingPeriods' => [
|
||||||
|
[
|
||||||
|
'from' => '2015-02-01',
|
||||||
|
'to' => '2015-10-30',
|
||||||
|
'remark' => 'oops',
|
||||||
|
],[
|
||||||
|
'from' => '2017-06-01',
|
||||||
|
'to' => '2018-03-30',
|
||||||
|
'remark' => 'argg',
|
||||||
|
],[
|
||||||
|
'from' => '2019-01-01',
|
||||||
|
'to' => '2019-12-31',
|
||||||
|
'remark' => 'blob',
|
||||||
|
]
|
||||||
|
]
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
//to have a person with same firstname as Gérard Depardieu
|
//to have a person with same firstname as Gérard Depardieu
|
||||||
@ -343,4 +362,22 @@ class LoadPeople extends AbstractFixture implements OrderedFixtureInterface, Con
|
|||||||
'maritalStatus' => 'ms_legalco'
|
'maritalStatus' => 'ms_legalco'
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
private function addAccompanyingPeriods(Person $person, array $periods, ObjectManager $manager)
|
||||||
|
{
|
||||||
|
foreach ($periods as $period) {
|
||||||
|
|
||||||
|
echo "adding new past Accompanying Period..\n";
|
||||||
|
|
||||||
|
/** @var AccompanyingPeriod $accompanyingPeriod */
|
||||||
|
$accompanyingPeriod = new AccompanyingPeriod(new \DateTime($period['from']));
|
||||||
|
$accompanyingPeriod
|
||||||
|
->setClosingDate(new \DateTime($period['to']))
|
||||||
|
->setRemark($period['remark'])
|
||||||
|
;
|
||||||
|
|
||||||
|
$person->addAccompanyingPeriod($accompanyingPeriod);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user