diff --git a/DataFixtures/ORM/LoadPeople.php b/DataFixtures/ORM/LoadPeople.php index 786f3bb07..c8c011175 100644 --- a/DataFixtures/ORM/LoadPeople.php +++ b/DataFixtures/ORM/LoadPeople.php @@ -1,6 +1,6 @@ years[] = $y; + $y = $y +1; + } while ($y >= 1990); + + + $m = 1; + do { + $this->month[] = $m; + $m = $m +1; + } while ($m >= 12); + + $d = 1; + do { + $this->day[] = $d; + $d = $d + 1; + } while ($d <= 28); + } + public function getOrder() { - return 1001; + return 1302; } public function load(ObjectManager $manager) { - foreach ($this->peoples as $person) { + + echo "loading people...\n"; + + $this->prepare(); + + $choose_name_or_tri = array('tri', 'tri', 'name', 'tri'); + + $i = 0; + + do { + + echo "add a person..."; + $i++; + + if ($choose_name_or_tri[array_rand($choose_name_or_tri)] === 'tri' ) { + $length = rand(2, 3); + $name = ''; + for ($j = 0; $j <= $length; $j++) { + $name .= $this->names_trigrams[array_rand($this->names_trigrams)]; + } + $name = ucfirst($name); + + } else { + $name = $this->names[array_rand($this->names)]; + } + + $person = array( + 'Name' => $name, + 'Surname' => $this->surnames[array_rand($this->surnames)], + 'DateOfBirth' => "1960-10-12", + 'PlaceOfBirth' => "Ottignies Louvain-La-Neuve", + 'Genre' => Person::GENRE_MAN, + 'CivilUnion' => Person::CIVIL_DIVORCED, + 'NbOfChild' => 0, + 'BelgianNationalNumber' => '12-10-16-269-24', + 'Email' => "Email d'un ami: roger@tt.com", + 'CountryOfBirth' => 'France', + 'Nationality' => 'Russie' + ); + $p = new Person(); foreach ($person as $key => $value) { @@ -40,11 +103,37 @@ class LoadPeople extends AbstractFixture { } var_dump($p); $manager->persist($p); - } + } while ($i <= 100); $manager->flush(); } + + private $surnames = array("Jean", "Mohamed", "Alfred", "Robert", "Svedana", "Sevlatina", + "Irène", "Marcelle", "Compère", "Jean-de-Dieu", "Corentine", "Alfonsine", + "Caroline", "Charles", "Pierre", "Luc", "Mathieu", "Alain", "Etienne", "Eric", + "Solange", "Corentin", "Gaston", "Spirou", "Fantasio", "Mahmadou", "Mohamidou", + "Vursuv", "Gostine"); + + private $names = array("Diallo", "Bah", "Gaillot"); + private $names_trigrams = 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'); + + private $genres = array(Person::GENRE_MAN, Person::GENRE_WOMAN); + + private $CivilUnions = array(Person::CIVIL_COHAB, Person::CIVIL_DIVORCED, + Person::CIVIL_SEPARATED, Person::CIVIL_SINGLE, Person::CIVIL_UNKNOW, + Person::CIVIL_WIDOW); + + private $NbOfChild = array(0, 0, 1, 1, 1, 1, 1, 2, 2, 3, 4, 5, 6); + + private $years = array(); + + private $month = array(); + + private $day = array(); + private $peoples = array( array( 'Name' => "Depardieu",