| @@ 40-59 (lines=20) @@ | ||
| 37 | * @Method({"GET", "POST"}) |
|
| 38 | * @Security("has_role('ROLE_ADMIN')") |
|
| 39 | */ |
|
| 40 | public function newCategoryRootAction(Request $request) |
|
| 41 | { |
|
| 42 | $entityManager = $this->getDoctrine()->getManager(); |
|
| 43 | $repo = $entityManager->getRepository('AppBundle\Entity\Category'); |
|
| 44 | $category = new Category(); |
|
| 45 | $form = $this->createForm(CategoryType::class, $category); |
|
| 46 | $form->handleRequest($request); |
|
| 47 | if ($form->isSubmitted() && $form->isValid()) { |
|
| 48 | $category->setParent(null); |
|
| 49 | $entityManager->persist($category); |
|
| 50 | $repo->verify(); |
|
| 51 | $repo->recover(); |
|
| 52 | $entityManager->flush(); |
|
| 53 | return $this->redirectToRoute('admin_categories'); |
|
| 54 | } |
|
| 55 | return $this->render('@App/admin/category/new_category_root.html.twig', array( |
|
| 56 | 'category' => $category, |
|
| 57 | 'form' => $form->createView(), |
|
| 58 | )); |
|
| 59 | } |
|
| 60 | ||
| 61 | /** |
|
| 62 | * @Route("/category/new", name="admin_category_new") |
|
| @@ 29-47 (lines=19) @@ | ||
| 26 | /** |
|
| 27 | * @Route("/register", name="user_registration") |
|
| 28 | */ |
|
| 29 | public function registerAction(Request $request) |
|
| 30 | { |
|
| 31 | $user = new User(); |
|
| 32 | $form = $this->createForm(UserType::class, $user); |
|
| 33 | $form->handleRequest($request); |
|
| 34 | if ($form->isSubmitted() && $form->isValid()) { |
|
| 35 | $password = $this->get('security.password_encoder') |
|
| 36 | ->encodePassword($user, $user->getPlainPassword()); |
|
| 37 | $user->setPassword($password); |
|
| 38 | $em = $this->getDoctrine()->getManager(); |
|
| 39 | $em->persist($user); |
|
| 40 | $em->flush(); |
|
| 41 | return $this->redirectToRoute('security_login_form'); |
|
| 42 | } |
|
| 43 | return $this->render( |
|
| 44 | 'AppBundle:security:register.html.twig', |
|
| 45 | array('form' => $form->createView()) |
|
| 46 | ); |
|
| 47 | } |
|
| 48 | ||
| 49 | /** |
|
| 50 | * @Route("/login_check", name="security_login_check") |
|