Example #1
0
 /**
  * newRegion
  *
  * @return Region $region
  */
 public function newRegion()
 {
     $country = $this->newCountry();
     $region = new Region();
     $region->setName($this->faker->city);
     $region->setCountry($country);
     $this->em->persist($region);
     $this->em->flush();
     return $region;
 }
Example #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);
             $region = null;
             foreach ($XML->database->table as $table) {
                 $country = $this->getReference('country_' . $table->column[4]);
                 // Spain
                 $region = new Region();
                 $region->setName($table->column[1]);
                 $region->setCountry($country);
                 $manager->persist($region);
                 $manager->flush();
             }
             $this->addReference('region_' . $table->column[0], $region);
         }
     }
 }