예제 #1
0
 public function load(ObjectManager $manager)
 {
     $categories = array(array('code' => 'A', 'name' => 'Vertrieb'), array('code' => 'B', 'name' => 'Produktion'), array('code' => 'C', 'name' => 'Montage'), array('code' => 'D', 'name' => 'Technik'), array('code' => 'E', 'name' => 'Übrige'), array('code' => 'F', 'name' => 'luuXa'));
     $subcategories = array('Administration', 'Management', 'Finance');
     $subsubcategories = array('classic/isolux', 'madera', 'imago', 'Läden', 'Schiebetüren', 'Sicherheit', 'Wärmeschutz', 'Alubauteile', 'Zubehör');
     $codeSubCat = 'A';
     $codeSubSubCat = 'A';
     foreach ($categories as $parent) {
         $categoryParent = new Category();
         $categoryParent->setName($parent['name']);
         $categoryParent->setCode($parent['code']);
         $categoryParent->setMain(true);
         $manager->persist($categoryParent);
     }
     foreach ($subcategories as $child) {
         $codeSubCat++;
         $subcategory = new Category();
         $subcategory->setName($child);
         $subcategory->setCode($codeSubCat);
         $subcategory->setMain(false);
         $manager->persist($subcategory);
         foreach ($subsubcategories as $subchild) {
             $codeSubSubCat++;
             $subsubcategory = new Category();
             $subsubcategory->setName($subchild);
             $subsubcategory->setCode($codeSubSubCat);
             $subsubcategory->setParent($subcategory);
             $subsubcategory->setMain(false);
             $manager->persist($subsubcategory);
         }
     }
     $manager->flush();
 }
예제 #2
0
 private function prepareDataForRender($mainCategories, $subCategories, $subsubcategories, $users)
 {
     $noneCategory = new Category();
     $noneCategory->setName("Keine");
     $noneCategory->setParent($noneCategory);
     $noneUser = new User();
     $noneUser->setLastname("Keine");
     array_unshift($mainCategories, $noneCategory);
     array_unshift($subsubcategories, $noneCategory);
     array_unshift($users, $noneUser);
     return array('maincategories' => $this->buildCategoriesForView($mainCategories, "", "checked"), 'subcategories' => $subCategories, 'subsubcategories' => $this->buildCategoriesForView($subsubcategories, "default-select", "selected"), 'users' => $users);
 }