示例#1
0
 public function createRootCategory(Administration $administration)
 {
     $rootCategory = new Category();
     $rootCategory->setAdministration($administration);
     $rootCategory->setTitle('category.root');
     $rootCategory->setType(Type::ROOT);
     return $rootCategory;
 }
示例#2
0
 public function isLastSibling()
 {
     if ($this->getRight() + 1 == $this->parent->getRight()) {
         return true;
     }
     return false;
 }
 /**
  * @Route("/categories/add", name="add_category")
  *
  * @param Request $request
  * @return Response
  */
 public function addCategoryAction(Request $request)
 {
     $administration = $this->checkCurrentAdministration(Permission::FULL_ACCESS);
     $category = new Category();
     $category->setAdministration($administration);
     $form = $this->createForm('category', $category);
     $form->handleRequest($request);
     if ($form->isValid()) {
         $em = $this->getDoctrine()->getManager();
         $repo = $em->getRepository('HomefinanceBundle:Category');
         $em->persist($category);
         $repo->verify();
         $repo->recover();
         $em->flush();
         $this->addFlash('success', 'category.added');
         return $this->redirect($this->generateUrl('categories'));
     }
     return $this->render('HomefinanceBundle:Administration:add_category.html.twig', array('form' => $form->createView()));
 }