|
@@ 73-82 (lines=10) @@
|
| 70 |
|
$category = new Category(); |
| 71 |
|
$form = $this->createForm(CategoryType::class, $category, array('isForm_cat' => true)); |
| 72 |
|
$form->handleRequest($request); |
| 73 |
|
if ($form->isSubmitted() && $form->isValid()) { |
| 74 |
|
$parent = $form['parent']->getData(); |
| 75 |
|
$category->setParent($parent); |
| 76 |
|
$parent->addChild($category); |
| 77 |
|
$entityManager->persist($category); |
| 78 |
|
$repo->verify(); |
| 79 |
|
$repo->recover(); |
| 80 |
|
$entityManager->flush(); |
| 81 |
|
return $this->redirectToRoute('admin_categories'); |
| 82 |
|
} |
| 83 |
|
return $this->render('@App/admin/category/new_category.html.twig', array( |
| 84 |
|
'category' => $category, |
| 85 |
|
'form' => $form->createView(), |
|
@@ 101-109 (lines=9) @@
|
| 98 |
|
$repo = $entityManager->getRepository('AppBundle\Entity\Category'); |
| 99 |
|
$editForm = $this->createForm(CategoryType::class, $category, array('isForm_cat' => true)); |
| 100 |
|
$editForm->handleRequest($request); |
| 101 |
|
if ($editForm->isSubmitted() && $editForm->isValid()) { |
| 102 |
|
$parent = $editForm['parent']->getData(); |
| 103 |
|
$category->setParent($parent); |
| 104 |
|
$entityManager->persist($category); |
| 105 |
|
$repo->verify(); |
| 106 |
|
$repo->recover(); |
| 107 |
|
$entityManager->flush(); |
| 108 |
|
return $this->redirectToRoute('admin_categories'); |
| 109 |
|
} |
| 110 |
|
return $this->render('@App/admin/category/edit_category.html.twig', array( |
| 111 |
|
'category' => $category, |
| 112 |
|
'edit_form' => $editForm->createView(), |