|
@@ 37-57 (lines=21) @@
|
| 34 |
|
* @Route(path="/admin/menu/category/{id}", name="admin_menu_category_edit") |
| 35 |
|
* @ParamConverter |
| 36 |
|
*/ |
| 37 |
|
public function categoryEditAction(Request $request, Category $category) |
| 38 |
|
{ |
| 39 |
|
$form = $this->createForm(CategoryType::class, $category); |
| 40 |
|
$form->handleRequest($request); |
| 41 |
|
|
| 42 |
|
if ($form->isSubmitted() && $form->isValid()) { |
| 43 |
|
$this->getDoctrine()->getManager()->flush(); |
| 44 |
|
|
| 45 |
|
$this->addFlash('success', sprintf( |
| 46 |
|
'Catégorie "%s" mise à jour.', |
| 47 |
|
$category->getName() |
| 48 |
|
)); |
| 49 |
|
|
| 50 |
|
return $this->redirectToRoute('admin_menu_index'); |
| 51 |
|
} |
| 52 |
|
|
| 53 |
|
return $this->render('admin_menu/category_edit.html.twig', array( |
| 54 |
|
'category' => $category, |
| 55 |
|
'form' => $form->createView() |
| 56 |
|
)); |
| 57 |
|
} |
| 58 |
|
|
| 59 |
|
/** |
| 60 |
|
* @Route(path="/admin/menu/create-category", name="admin_menu_category_create") |
|
@@ 114-134 (lines=21) @@
|
| 111 |
|
* @Route(path="/admin/menu/meal/{id}", name="admin_menu_meal_edit") |
| 112 |
|
* @ParamConverter |
| 113 |
|
*/ |
| 114 |
|
public function mealEditAction(Request $request, Meal $meal) |
| 115 |
|
{ |
| 116 |
|
$form = $this->createForm(MealType::class, $meal); |
| 117 |
|
$form->handleRequest($request); |
| 118 |
|
|
| 119 |
|
if ($form->isSubmitted() && $form->isValid()) { |
| 120 |
|
$this->getDoctrine()->getManager()->flush(); |
| 121 |
|
|
| 122 |
|
$this->addFlash('success', sprintf( |
| 123 |
|
'Plat "%s" mis à jour.', |
| 124 |
|
$meal->getName() |
| 125 |
|
)); |
| 126 |
|
|
| 127 |
|
return $this->redirectToRoute('admin_menu_category_edit', array('id' => $meal->getCategory()->getId())); |
| 128 |
|
} |
| 129 |
|
|
| 130 |
|
return $this->render('admin_menu/meal_edit.html.twig', array( |
| 131 |
|
'meal' => $meal, |
| 132 |
|
'form' => $form->createView() |
| 133 |
|
)); |
| 134 |
|
} |
| 135 |
|
|
| 136 |
|
/** |
| 137 |
|
* @Route(path="/admin/menu/create-meal/{id}", name="admin_menu_meal_create") |