示例#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('page_category_' . $table->column[2]);
                 }
                 $category = new Category();
                 $category->setLocale($table->column[1]);
                 $category->setTitle($table->column[3]);
                 $category->setDescription($table->column[8]);
                 $category->setStatus($table->column[9]);
                 $category->setMetaUrl($table->column[10]);
                 if ($rootCategory) {
                     $category->setParent($rootCategory);
                 }
                 $manager->persist($category);
                 $manager->flush();
                 $this->addReference('page_category_' . $table->column[0], $category);
             }
         }
     }
 }
示例#2
0
 public function createNode($name)
 {
     $node = new Category();
     $node->setLocale('en');
     $node->setDescription('');
     $node->setMetaUrl('/');
     $node->setTitle($name);
     $this->em->persist($node);
     $this->em->flush();
     return $node;
 }