/** * newCountry * * @return Country $country */ public function newCountry() { $country = new Country(); $country->setIso2($this->faker->countryCode); $country->setIso3($this->faker->countryISOAlpha3); $country->setShortName($this->faker->country); $country->setLongName($this->faker->country); $country->setNumcode($this->faker->numberBetween()); $country->setCallingCode($this->faker->numberBetween()); $country->setCctld($this->faker->domainWord); $this->em->persist($country); $this->em->flush(); return $country; }
/** * {@inheritDoc} */ public function load(ObjectManager $manager) { foreach ($this->fixtureFiles as $file) { if (file_exists($file)) { $contents = file_get_contents($file); $XML = simplexml_load_string($contents); foreach ($XML->database->table as $table) { $country = new Country(); $country->setIso2($table->column[1]); $country->setIso3($table->column[2]); $country->setShortName($table->column[3]); $country->setLongName($table->column[4]); $country->setNumcode($table->column[5]); $country->setUnMember($table->column[6]); $country->setCallingCode($table->column[7]); $country->setCctld($table->column[8]); $manager->persist($country); $manager->flush(); $this->addReference('country_' . $table->column[0], $country); } } } }