public function executeAddregion() { $c = new Criteria(); $c->add(RegionPeer::NAME, $this->getRequestParameter('region')); $exregion = RegionPeer::doSelectOne($c); if ($exregion) { $this->setFlash('notice', 'Region could not be added. A Region with this name already exists.'); } else { $region = new Region(); $region->setName($this->getRequestParameter('region')); $region->save(); $this->setFlash('notice', 'Region <b>' . $region->getName() . '</b> added successfully'); } $this->redirect('admin/regions'); }
public function getRegions() { $regions = json_decode(file_get_contents(__DIR__ . "/../Resources/regions.json")); foreach ($regions as $region) { $reg = new Region(); $reg->setName($region->name); $reg->setWsId($region->id); $reg->setType($region->type); foreach ($region->tournaments as $tournament) { $tour = new Tournament(); $tour->setRegion($reg); $tour->setWsId($tournament->id); $tour->setName($tournament->name); $this->em->persist($tour); } $this->em->persist($reg); } $this->em->flush(); }