Exemplo n.º 1
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);
             foreach ($XML->database->table as $table) {
                 $rootCategory = null;
                 if ($table->column[2] != 'NULL') {
                     $rootCategory = $this->getReference('menu_top_' . $table->column[2]);
                 }
                 $menu = new Menu();
                 $menu->setLocale($table->column[1]);
                 $menu->setTitle($table->column[7]);
                 $menu->setMetaUrl($table->column[8]);
                 $menu->setStatus((int) $table->column[9]);
                 if ($rootCategory) {
                     $menu->setParent($rootCategory);
                 }
                 $manager->persist($menu);
                 $manager->flush();
                 $this->addReference('menu_top_' . $table->column[0], $menu);
             }
         }
     }
 }
 public function createNode($name)
 {
     $node = new Menu();
     $node->setLocale('en');
     $node->setMetaUrl('/');
     $node->setTitle($name);
     $node->setStatus($name);
     $this->dm->persist($node);
     $this->dm->flush();
     return $node;
 }