Esempio n. 1
0
 public function load(ObjectManager $manager)
 {
     $tab_Categories = array(array("nom" => "fruit", "description" => "Fruit", "media" => $manager->getRepository('ECommerceECommerceBundle:Media')->findOneBy(array('nom' => 'fruit'))), array("nom" => "legume", "description" => "legume", "media" => $manager->getRepository('ECommerceECommerceBundle:Media')->findOneBy(array('nom' => 'legume'))));
     for ($i = 0; $i < sizeof($tab_Categories); $i++) {
         $categorie = new Categorie();
         $categorie->setNom($tab_Categories[$i]['nom']);
         $categorie->setDescription($tab_Categories[$i]['description']);
         $categorie->setMedia($tab_Categories[$i]['media']);
         $manager->persist($categorie);
     }
     $manager->flush();
 }
Esempio n. 2
0
 public function load(ObjectManager $manager)
 {
     $categorie1 = new Categorie();
     $categorie1->setNom('Legumes');
     $categorie1->setImage($this->getReference('Media1'));
     $manager->persist($categorie1);
     $categorie2 = new Categorie();
     $categorie2->setNom('Fruits');
     $categorie2->setImage($this->getReference('Media2'));
     $manager->persist($categorie2);
     $manager->flush();
     $this->addReference('categorie1', $categorie1);
     $this->addReference('categorie2', $categorie2);
 }
 public function setNom($nom)
 {
     $this->__load();
     return parent::setNom($nom);
 }