public function load($manager) { $currency = new \Club\UserBundle\Entity\Currency(); $currency->setCurrencyName('US Dollar'); $currency->setCode('USD'); $currency->setSymbolLeft('$'); $currency->setDecimalPlaces(2); $currency->setValue(1); $currency->setActive(0); $manager->persist($currency); $currency = new \Club\UserBundle\Entity\Currency(); $currency->setCurrencyName('Euro'); $currency->setCode('EUR'); $currency->setSymbolLeft('€'); $currency->setDecimalPlaces(2); $currency->setValue(1); $currency->setActive(0); $manager->persist($currency); $currency = new \Club\UserBundle\Entity\Currency(); $currency->setCurrencyName('Danish Krone'); $currency->setCode('DKK'); $currency->setSymbolRight('DK'); $currency->setDecimalPlaces(2); $currency->setValue(1); $currency->setActive(0); $manager->persist($currency); $manager->flush(); }
private function initCurrency() { $c = array(array('code' => 'USD', 'name' => 'US Dollar'), array('code' => 'EUR', 'name' => 'Euro'), array('code' => 'DKK', 'name' => 'Danish Krone')); foreach ($c as $currency) { $r = $this->em->getRepository('ClubUserBundle:Currency')->findOneBy(array('code' => $currency['code'])); if (!$r) { $cur = new \Club\UserBundle\Entity\Currency(); $cur->setCurrencyName($currency['name']); $cur->setCode($currency['code']); $this->em->persist($cur); } } }