Ejemplo n.º 1
0
 /**
  * {@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);
             $city = null;
             foreach ($XML->database->table as $table) {
                 $country = $this->getReference('country_' . $table->column[4]);
                 // Spain
                 $region = $this->getReference('region_' . $table->column[5]);
                 // City of Madrid
                 $city = new City();
                 $city->setName($table->column[1]);
                 $city->setRegion($region);
                 $city->setCountry($country);
                 $manager->persist($city);
                 $manager->flush();
             }
             $this->addReference('city_' . $table->column[0], $city);
         }
     }
 }