diff --git a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadPeople.php b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadPeople.php index 1419aa47a..fa20d3457 100644 --- a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadPeople.php +++ b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadPeople.php @@ -21,6 +21,7 @@ namespace Chill\PersonBundle\DataFixtures\ORM; +use Chill\PersonBundle\Entity\AccompanyingPeriod; use Doctrine\Common\DataFixtures\AbstractFixture; use Doctrine\Common\DataFixtures\OrderedFixtureInterface; use Doctrine\Persistence\ObjectManager; @@ -195,6 +196,9 @@ class LoadPeople extends AbstractFixture implements OrderedFixtureInterface, Con case 'maritalStatus': $value = $this->getReference($value); break; + case 'accompanyingPeriods': + $this->addAccompanyingPeriods($p, $value, $manager); + break; } //try to add the data using the setSomething function, @@ -230,15 +234,15 @@ class LoadPeople extends AbstractFixture implements OrderedFixtureInterface, Con private function getRandomAddress() { return (new Address()) - ->setStreetAddress1($this->faker->streetAddress) - ->setStreetAddress2( - rand(0,9) > 5 ? $this->faker->streetAddress : '' - ) - ->setPostcode($this->getReference( - LoadPostalCodes::$refs[array_rand(LoadPostalCodes::$refs)] - )) - ->setValidFrom($this->faker->dateTimeBetween('-5 years')) - ; + ->setStreetAddress1($this->faker->streetAddress) + ->setStreetAddress2( + rand(0,9) > 5 ? $this->faker->streetAddress : '' + ) + ->setPostcode($this->getReference( + LoadPostalCodes::$refs[array_rand(LoadPostalCodes::$refs)] + )) + ->setValidFrom($this->faker->dateTimeBetween('-5 years')) + ; } private function getCountry($countryCode) @@ -251,25 +255,25 @@ class LoadPeople extends AbstractFixture implements OrderedFixtureInterface, Con ->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']; - private $firstNamesMale = array("Jean", "Mohamed", "Alfred", "Robert", - "Compère", "Jean-de-Dieu", - "Charles", "Pierre", "Luc", "Mathieu", "Alain", "Etienne", "Eric", - "Corentin", "Gaston", "Spirou", "Fantasio", "Mahmadou", "Mohamidou", - "Vursuv" ); - private $firstNamesFemale = array("Svedana", "Sevlatina","Irène", "Marcelle", - "Corentine", "Alfonsine","Caroline","Solange","Gostine", "Fatoumata", - "Groseille", "Chana", "Oxana", "Ivana"); + private $firstNamesMale = array("Jean", "Mohamed", "Alfred", "Robert", "Justin", "Brian", + "Compère", "Jean-de-Dieu", "Charles", "Pierre", "Luc", "Mathieu", "Alain", "Etienne", "Eric", + "Corentin", "Gaston", "Spirou", "Fantasio", "Mahmadou", "Mohamidou", "Vursuv", "Youssef" ); + + private $firstNamesFemale = array("Svedana", "Sevlatina", "Irène", "Marcelle", + "Corentine", "Alfonsine", "Caroline", "Solange", "Gostine", "Fatoumata", "Nicole", + "Groseille", "Chana", "Oxana", "Ivana", "Julie", "Tina", "Adèle" ); + + private $lastNames = array("Diallo", "Bah", "Gaillot", "Martin"); - private $lastNames = array("Diallo", "Bah", "Gaillot"); private $lastNamesTrigrams = array("fas", "tré", "hu", 'blart', 'van', 'der', 'lin', 'den', - 'ta', 'mi', 'gna', 'bol', 'sac', 'ré', 'jo', 'du', 'pont', 'cas', 'tor', 'rob', 'al', - 'ma', 'gone', 'car',"fu", "ka", "lot", "no", "va", "du", "bu", "su", + '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", "jau", "tte", 'sir', "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(); @@ -287,7 +291,22 @@ class LoadPeople extends AbstractFixture implements OrderedFixtureInterface, Con 'CountryOfBirth' => 'FR', 'Nationality' => 'RU', '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( //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' ), ); + + + 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); + } + } }