private function createTestCharacter() { $charac = Charac::withAttributes("Michel", 1, "Testeur", "Humain", "M"); $guild = Guild::withAttributes("Les michels test", "http://www.google.com/montest.jpg"); $register = Register::withAttributes(1, 2, $charac, $guild); $boot = Boot::withAttributes($charac, "Bottes de fermier", 1, 2, 3); $helmet = Helmet::withAttributes($charac, "Casque de chantier", 3, 2, 1); $this->em->persist($charac); $this->em->persist($guild); $this->em->persist($register); $this->em->persist($boot); $this->em->persist($helmet); $this->em->flush(); $id = $charac->getId(); return $id; }
/** * {@inheritDoc} */ public function load(ObjectManager $manager) { /* Values randomly selectable */ $dataSets = new stdClass(); $dataSets->charNames = array("Sam Fisher", "Tom Clancy", "Agent 49", "Jason Bourne", "Homer Simpson", "Tom", "Jerry", "Clover", "Sam", "Alex", "Jean M.", "Andrieuman", "Leguman", "Force Bleue", "Force Rouge", "Force Jaune devant Marron derriere", "Julien Lepers", "Michel Sardou"); $dataSets->classNames = array("Discret", "Bourrin", "Manipulateur", "Fort", "Faible", "Observateur", "Soutien", "Support", "Medecin", "Chef de groupe", "Chef d'équipe", "Logger"); $dataSets->raceNames = array("Tueurs", "Defenseurs", "Anihilateurs", "Animateurs TV", "Personnages de mangas", "Eleves de l'IMIE", "What the f**k", "Personnages de films"); $dataSets->genders = array("M", "F"); $dataSets->stuffNamesBoots = array("Rangers", "Chaussures de ville", "Bottes", "Talons hauts", "Skis", "Raquettes", "Patins a glace", "Rollers", "Chaussettes", "Tongs", "Chaussures de chantier"); $dataSets->stuffNamesHelmets = array("Casque de vision nocturne", "Casque anti émeute", "Casque de l'armée", "Casquette Wati-B", "Oreilles de lapin", "Chapeau d'hotesse de l'air", "Bonnet blanc dégeulasse", "Képi", "Les cheveux de Jean", "Coiffure de vieille"); $dataSets->minStuffNb = 1; $dataSets->maxStuffNb = 30; $dataSets->guildNames = array("Les forces spéciales", "Les tueurs", "Les gentils", "Les méchants", "Les gens cools", "Questions pour un champion", "Le Crazy Horse", "Chez Momo"); $dataSets->banners = array("http://upload.wikimedia.org/wikipedia/commons/b/b6/Junction_42.svg", "http://upload.wikimedia.org/wikipedia/commons/5/56/Answer_to_Life.png", "http://referentiel.nouvelobs.com/file/6651944.jpg", "http://www.geekbecois.com/wp-content/uploads/2014/11/42.png", "http://thednetworks.com/wp-content/uploads/2011/10/600px-US_42.png"); /* Initialize Guilds */ $guilds = array(); foreach ($dataSets->guildNames as $gn) { $guild = Guild::withAttributes($gn, $dataSets->banners[array_rand($dataSets->banners)]); $manager->persist($guild); $guilds[] = $guild; } /* Initialize characters */ for ($sfI = 0; $sfI < 30; $sfI++) { $charac = Charac::withAttributes($dataSets->charNames[array_rand($dataSets->charNames)], rand(1, 1000), $dataSets->classNames[array_rand($dataSets->classNames)], $dataSets->raceNames[array_rand($dataSets->raceNames)], $dataSets->genders[array_rand($dataSets->genders)]); $nbStuffs = rand($dataSets->minStuffNb, $dataSets->maxStuffNb); for ($sfJ = 0; $sfJ < $nbStuffs; $sfJ++) { if (rand(0, 1)) { $stuff = Boot::withAttributes($charac, $dataSets->stuffNamesBoots[array_rand($dataSets->stuffNamesBoots)], rand(1, 100), rand(30, 40), rand(100, 4000)); } else { $stuff = Helmet::withAttributes($charac, $dataSets->stuffNamesHelmets[array_rand($dataSets->stuffNamesHelmets)], rand(1, 100), rand(30, 40), rand(100, 4000)); } $manager->persist($stuff); } $manager->persist($charac); /* Make a registration */ $registration = Register::withAttributes(rand(0, 9999), rand(0, 9999), $charac, $guilds[array_rand($guilds)]); $manager->persist($registration); } $manager->flush(); }