Ejemplo n.º 1
0
 /**
  * newCity
  *
  * @return City $region
  */
 public function newCity()
 {
     $region = $this->newRegion();
     $city = new City();
     $city->setName($this->faker->city);
     $city->setRegion($region);
     $this->em->persist($city);
     $this->em->flush();
     return $city;
 }
Ejemplo n.º 2
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) {
                 $region = $this->getReference('region_' . $table->column[5]);
                 // City of Madrid
                 $city = new City();
                 $city->setName($table->column[1]);
                 $city->setRegion($region);
                 $manager->persist($city);
                 $manager->flush();
             }
             $this->addReference('city_' . $table->column[0], $city);
         }
     }
 }