/** * @Route("/", name="admin") * @Template() */ public function adminAction() { $em = $this->getDoctrine()->getManager(); $config = new Config($em, 'Appbundle\\Entity\\Category'); $nsm = new Manager($config); //FOR GETTING TREE $rootNode = $nsm->fetchTree(15); /*$category = new Category(); $category->setName('Obiloviny'); $category->setUrlName('obiloviny');*/ // FOR ADDING ROOT CATEGORY //$rootNode = $nsm->createRoot($category); // FOR ADDING CHILD //$rootNode->addChild($category); //$this->addFlash("success", "child node přidán"); dump($nsm->fetchTreeAsArray(15)); return ["tree" => $nsm->fetchTreeAsArray(15)]; }
/** * @Route("/menuLiCategories", name="main_menuLiCategories") * @Template() */ public function menuLiCategoriesAction() { $em = $this->getDoctrine()->getManager(); $config = new Config($em); $nsm = new Manager($config); /* $categories = $this->getDoctrine() ->getRepository("AppBundle:Category") ->findBy(['parent' => null]); */ $categories = array_merge($nsm->fetchTreeAsArray(13), $nsm->fetchTreeAsArray(15), $nsm->fetchTreeAsArray(16)); return ['categories' => $categories]; }