コード例 #1
0
ファイル: Builder.php プロジェクト: jaapjansma/homefinance
 public function createRootCategory(Administration $administration)
 {
     $rootCategory = new Category();
     $rootCategory->setAdministration($administration);
     $rootCategory->setTitle('category.root');
     $rootCategory->setType(Type::ROOT);
     return $rootCategory;
 }
コード例 #2
0
ファイル: Category.php プロジェクト: jaapjansma/homefinance
 public function isLastSibling()
 {
     if ($this->getRight() + 1 == $this->parent->getRight()) {
         return true;
     }
     return false;
 }
コード例 #3
0
 /**
  * @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()));
 }