| @@ 18-194 (lines=177) @@ | ||
| 15 | * |
|
| 16 | * @Route("/admin/settings/divers/familylog") |
|
| 17 | */ |
|
| 18 | class FamilyLogController extends Controller |
|
| 19 | { |
|
| 20 | /** |
|
| 21 | * Lists all FamilyLog entities. |
|
| 22 | * |
|
| 23 | * @Route("/", name="admin_familylog") |
|
| 24 | * @Method("GET") |
|
| 25 | * @Template() |
|
| 26 | */ |
|
| 27 | public function indexAction() |
|
| 28 | { |
|
| 29 | $em = $this->getDoctrine()->getManager(); |
|
| 30 | $entities = $em->getRepository('AppBundle:FamilyLog')->findAll(); |
|
| 31 | ||
| 32 | return array( |
|
| 33 | 'entities' => $entities, |
|
| 34 | ); |
|
| 35 | } |
|
| 36 | ||
| 37 | /** |
|
| 38 | * Finds and displays a FamilyLog entity. |
|
| 39 | * |
|
| 40 | * @Route("/{slug}/show", name="admin_familylog_show") |
|
| 41 | * @Method("GET") |
|
| 42 | * @Template() |
|
| 43 | */ |
|
| 44 | public function showAction(FamilyLog $familylog) |
|
| 45 | { |
|
| 46 | $deleteForm = $this->createDeleteForm($familylog->getId(), 'admin_familylog_delete'); |
|
| 47 | ||
| 48 | return array( |
|
| 49 | 'familylog' => $familylog, |
|
| 50 | 'delete_form' => $deleteForm->createView(), |
|
| 51 | ); |
|
| 52 | } |
|
| 53 | ||
| 54 | /** |
|
| 55 | * Displays a form to create a new FamilyLog entity. |
|
| 56 | * |
|
| 57 | * @Route("/new", name="admin_familylog_new") |
|
| 58 | * @Method("GET") |
|
| 59 | * @Template() |
|
| 60 | */ |
|
| 61 | public function newAction() |
|
| 62 | { |
|
| 63 | $familylog = new FamilyLog(); |
|
| 64 | $form = $this->createForm(new FamilyLogType(), $familylog); |
|
| 65 | ||
| 66 | return array( |
|
| 67 | 'familylog' => $familylog, |
|
| 68 | 'form' => $form->createView(), |
|
| 69 | ); |
|
| 70 | } |
|
| 71 | ||
| 72 | /** |
|
| 73 | * Creates a new FamilyLog entity. |
|
| 74 | * |
|
| 75 | * @Route("/create", name="admin_familylog_create") |
|
| 76 | * @Method("POST") |
|
| 77 | * @Template("AppBundle:FamilyLog:new.html.twig") |
|
| 78 | */ |
|
| 79 | public function createAction(Request $request) |
|
| 80 | { |
|
| 81 | $familylog = new FamilyLog(); |
|
| 82 | $form = $this->createForm(new FamilyLogType(), $familylog); |
|
| 83 | if ($form->handleRequest($request)->isValid()) { |
|
| 84 | $em = $this->getDoctrine()->getManager(); |
|
| 85 | $em->persist($familylog); |
|
| 86 | $em->flush(); |
|
| 87 | ||
| 88 | if ($form->get('save')->isClicked()) { |
|
| 89 | $url = $this->redirect($this->generateUrl( |
|
| 90 | 'admin_familylog_show', |
|
| 91 | array('slug' => $familylog->getSlug()) |
|
| 92 | )); |
|
| 93 | } elseif ($form->get('addmore')->isClicked()) { |
|
| 94 | $this->addFlash('info', 'gestock.settings.add_ok'); |
|
| 95 | $url = $this->redirectToRoute('admin_familylog_new'); |
|
| 96 | } |
|
| 97 | return $url; |
|
| 98 | } |
|
| 99 | ||
| 100 | return array( |
|
| 101 | 'familylog' => $familylog, |
|
| 102 | 'form' => $form->createView(), |
|
| 103 | ); |
|
| 104 | } |
|
| 105 | ||
| 106 | /** |
|
| 107 | * Displays a form to edit an existing FamilyLog entity. |
|
| 108 | * |
|
| 109 | * @Route("/{slug}/edit", name="admin_familylog_edit") |
|
| 110 | * @Method("GET") |
|
| 111 | * @Template() |
|
| 112 | */ |
|
| 113 | public function editAction(FamilyLog $familylog) |
|
| 114 | { |
|
| 115 | $editForm = $this->createForm(new FamilyLogType(), $familylog, array( |
|
| 116 | 'action' => $this->generateUrl( |
|
| 117 | 'admin_familylog_update', |
|
| 118 | array('slug' => $familylog->getSlug()) |
|
| 119 | ), |
|
| 120 | 'method' => 'PUT', |
|
| 121 | )); |
|
| 122 | $deleteForm = $this->createDeleteForm($familylog->getId(), 'admin_familylog_delete'); |
|
| 123 | ||
| 124 | return array( |
|
| 125 | 'familylog' => $familylog, |
|
| 126 | 'edit_form' => $editForm->createView(), |
|
| 127 | 'delete_form' => $deleteForm->createView(), |
|
| 128 | ); |
|
| 129 | } |
|
| 130 | ||
| 131 | /** |
|
| 132 | * Edits an existing FamilyLog entity. |
|
| 133 | * |
|
| 134 | * @Route("/{slug}/update", name="admin_familylog_update") |
|
| 135 | * @Method("PUT") |
|
| 136 | * @Template("AppBundle:FamilyLog:edit.html.twig") |
|
| 137 | */ |
|
| 138 | public function updateAction(FamilyLog $famlog, Request $request) |
|
| 139 | { |
|
| 140 | $editForm = $this->createForm(new FamilyLogType(), $famlog, array( |
|
| 141 | 'action' => $this->generateUrl( |
|
| 142 | 'admin_familylog_update', |
|
| 143 | array('slug' => $famlog->getSlug()) |
|
| 144 | ), |
|
| 145 | 'method' => 'PUT', |
|
| 146 | )); |
|
| 147 | if ($editForm->handleRequest($request)->isValid()) { |
|
| 148 | $this->getDoctrine()->getManager()->flush(); |
|
| 149 | ||
| 150 | return $this->redirectToRoute('admin_familylog_edit', array('slug' => $famlog->getSlug())); |
|
| 151 | } |
|
| 152 | $deleteForm = $this->createDeleteForm($famlog->getId(), 'admin_familylog_delete'); |
|
| 153 | ||
| 154 | return array( |
|
| 155 | 'familylog' => $famlog, |
|
| 156 | 'edit_form' => $editForm->createView(), |
|
| 157 | 'delete_form' => $deleteForm->createView(), |
|
| 158 | ); |
|
| 159 | } |
|
| 160 | ||
| 161 | /** |
|
| 162 | * Deletes a FamilyLog entity. |
|
| 163 | * |
|
| 164 | * @Route("/{id}/delete", name="admin_familylog_delete", requirements={"id"="\d+"}) |
|
| 165 | * @Method("DELETE") |
|
| 166 | */ |
|
| 167 | public function deleteAction(FamilyLog $familylog, Request $request) |
|
| 168 | { |
|
| 169 | $form = $this->createDeleteForm($familylog->getId(), 'admin_familylog_delete'); |
|
| 170 | if ($form->handleRequest($request)->isValid()) { |
|
| 171 | $em = $this->getDoctrine()->getManager(); |
|
| 172 | $em->remove($familylog); |
|
| 173 | $em->flush(); |
|
| 174 | } |
|
| 175 | ||
| 176 | return $this->redirectToRoute('admin_familylog'); |
|
| 177 | } |
|
| 178 | ||
| 179 | /** |
|
| 180 | * Create Delete form |
|
| 181 | * |
|
| 182 | * @param integer $id |
|
| 183 | * @param string $route |
|
| 184 | * @return \Symfony\Component\Form\Form |
|
| 185 | */ |
|
| 186 | protected function createDeleteForm($id, $route) |
|
| 187 | { |
|
| 188 | return $this->createFormBuilder(null, array('attr' => array('id' => 'delete'))) |
|
| 189 | ->setAction($this->generateUrl($route, array('id' => $id))) |
|
| 190 | ->setMethod('DELETE') |
|
| 191 | ->getForm() |
|
| 192 | ; |
|
| 193 | } |
|
| 194 | } |
|
| 195 | ||
| @@ 18-186 (lines=169) @@ | ||
| 15 | * |
|
| 16 | * @Route("/admin/settings/divers/zonestorage") |
|
| 17 | */ |
|
| 18 | class ZoneStorageController extends Controller |
|
| 19 | { |
|
| 20 | /** |
|
| 21 | * Lists all ZoneStorage entities. |
|
| 22 | * |
|
| 23 | * @Route("/", name="admin_zonestorage") |
|
| 24 | * @Method("GET") |
|
| 25 | * @Template() |
|
| 26 | */ |
|
| 27 | public function indexAction() |
|
| 28 | { |
|
| 29 | $em = $this->getDoctrine()->getManager(); |
|
| 30 | $entities = $em->getRepository('AppBundle:ZoneStorage')->findAll(); |
|
| 31 | ||
| 32 | return array( |
|
| 33 | 'entities' => $entities, |
|
| 34 | ); |
|
| 35 | } |
|
| 36 | ||
| 37 | /** |
|
| 38 | * Finds and displays a ZoneStorage entity. |
|
| 39 | * |
|
| 40 | * @Route("/{slug}/show", name="admin_zonestorage_show") |
|
| 41 | * @Method("GET") |
|
| 42 | * @Template() |
|
| 43 | */ |
|
| 44 | public function showAction(ZoneStorage $zonestorage) |
|
| 45 | { |
|
| 46 | $deleteForm = $this->createDeleteForm($zonestorage->getId(), 'admin_zonestorage_delete'); |
|
| 47 | ||
| 48 | return array( |
|
| 49 | 'zonestorage' => $zonestorage, |
|
| 50 | 'delete_form' => $deleteForm->createView(), |
|
| 51 | ); |
|
| 52 | } |
|
| 53 | ||
| 54 | /** |
|
| 55 | * Displays a form to create a new ZoneStorage entity. |
|
| 56 | * |
|
| 57 | * @Route("/new", name="admin_zonestorage_new") |
|
| 58 | * @Method("GET") |
|
| 59 | * @Template() |
|
| 60 | */ |
|
| 61 | public function newAction() |
|
| 62 | { |
|
| 63 | $zonestorage = new ZoneStorage(); |
|
| 64 | $form = $this->createForm(new ZoneStorageType(), $zonestorage); |
|
| 65 | ||
| 66 | return array( |
|
| 67 | 'zonestorage' => $zonestorage, |
|
| 68 | 'form' => $form->createView(), |
|
| 69 | ); |
|
| 70 | } |
|
| 71 | ||
| 72 | /** |
|
| 73 | * Creates a new ZoneStorage entity. |
|
| 74 | * |
|
| 75 | * @Route("/create", name="admin_zonestorage_create") |
|
| 76 | * @Method("POST") |
|
| 77 | * @Template("AppBundle:Settings/Divers/ZoneStorage:new.html.twig") |
|
| 78 | */ |
|
| 79 | public function createAction(Request $request) |
|
| 80 | { |
|
| 81 | $zonestorage = new ZoneStorage(); |
|
| 82 | $form = $this->createForm(new ZoneStorageType(), $zonestorage); |
|
| 83 | if ($form->handleRequest($request)->isValid()) { |
|
| 84 | $em = $this->getDoctrine()->getManager(); |
|
| 85 | $em->persist($zonestorage); |
|
| 86 | $em->flush(); |
|
| 87 | ||
| 88 | if ($form->get('save')->isClicked()) { |
|
| 89 | $url = $this->redirectToRoute('admin_znoestorage_show', array('slug' => $zonestorage->getSlug())); |
|
| 90 | } elseif ($form->get('addmore')->isClicked()) { |
|
| 91 | $this->addFlash('info', 'gestock.settings.add_ok'); |
|
| 92 | $url = $this->redirect($this->generateUrl('admin_zonestorage_new')); |
|
| 93 | } |
|
| 94 | return $url; |
|
| 95 | } |
|
| 96 | ||
| 97 | return array( |
|
| 98 | 'zonestorage' => $zonestorage, |
|
| 99 | 'form' => $form->createView(), |
|
| 100 | ); |
|
| 101 | } |
|
| 102 | ||
| 103 | /** |
|
| 104 | * Displays a form to edit an existing ZoneStorage entity. |
|
| 105 | * |
|
| 106 | * @Route("/{slug}/edit", name="admin_zonestorage_edit") |
|
| 107 | * @Method("GET") |
|
| 108 | * @Template() |
|
| 109 | */ |
|
| 110 | public function editAction(ZoneStorage $zonestorage) |
|
| 111 | { |
|
| 112 | $editForm = $this->createForm(new ZoneStorageType(), $zonestorage, array( |
|
| 113 | 'action' => $this->generateUrl('admin_zonestorage_update', array('slug' => $zonestorage->getSlug())), |
|
| 114 | 'method' => 'PUT', |
|
| 115 | )); |
|
| 116 | $deleteForm = $this->createDeleteForm($zonestorage->getId(), 'admin_zonestorage_delete'); |
|
| 117 | ||
| 118 | return array( |
|
| 119 | 'zonestorage' => $zonestorage, |
|
| 120 | 'edit_form' => $editForm->createView(), |
|
| 121 | 'delete_form' => $deleteForm->createView(), |
|
| 122 | ); |
|
| 123 | } |
|
| 124 | ||
| 125 | /** |
|
| 126 | * Edits an existing ZoneStorage entity. |
|
| 127 | * |
|
| 128 | * @Route("/{slug}/update", name="admin_zonestorage_update") |
|
| 129 | * @Method("PUT") |
|
| 130 | * @Template("AppBundle:Settings/Divers/ZoneStorage:edit.html.twig") |
|
| 131 | */ |
|
| 132 | public function updateAction(ZoneStorage $zonestorage, Request $request) |
|
| 133 | { |
|
| 134 | $editForm = $this->createForm(new ZoneStorageType(), $zonestorage, array( |
|
| 135 | 'action' => $this->generateUrl('admin_zonestorage_update', array('slug' => $zonestorage->getSlug())), |
|
| 136 | 'method' => 'PUT', |
|
| 137 | )); |
|
| 138 | if ($editForm->handleRequest($request)->isValid()) { |
|
| 139 | $this->getDoctrine()->getManager()->flush(); |
|
| 140 | ||
| 141 | return $this->redirectToRoute('admin_zonestorage_edit', array('slug' => $zonestorage->getSlug())); |
|
| 142 | } |
|
| 143 | $deleteForm = $this->createDeleteForm($zonestorage->getId(), 'admin_zonestorage_delete'); |
|
| 144 | ||
| 145 | return array( |
|
| 146 | 'zonestorage' => $zonestorage, |
|
| 147 | 'edit_form' => $editForm->createView(), |
|
| 148 | 'delete_form' => $deleteForm->createView(), |
|
| 149 | ); |
|
| 150 | } |
|
| 151 | ||
| 152 | /** |
|
| 153 | * Deletes a ZoneStorage entity. |
|
| 154 | * |
|
| 155 | * @Route("/{id}/delete", name="admin_zonestorage_delete", requirements={"id"="\d+"}) |
|
| 156 | * @Method("DELETE") |
|
| 157 | */ |
|
| 158 | public function deleteAction(ZoneStorage $zonestorage, Request $request) |
|
| 159 | { |
|
| 160 | $form = $this->createDeleteForm($zonestorage->getId(), 'admin_zonestorage_delete'); |
|
| 161 | if ($form->handleRequest($request)->isValid()) { |
|
| 162 | $em = $this->getDoctrine()->getManager(); |
|
| 163 | $em->remove($zonestorage); |
|
| 164 | $em->flush(); |
|
| 165 | } |
|
| 166 | ||
| 167 | return $this->redirectToRoute('admin_zonestorage'); |
|
| 168 | } |
|
| 169 | ||
| 170 | /** |
|
| 171 | * Create Delete form |
|
| 172 | * |
|
| 173 | * @param integer $id |
|
| 174 | * @param string $route |
|
| 175 | * @return \Symfony\Component\Form\Form |
|
| 176 | */ |
|
| 177 | protected function createDeleteForm($id, $route) |
|
| 178 | { |
|
| 179 | return $this->createFormBuilder(null, array('attr' => array('id' => 'delete'))) |
|
| 180 | ->setAction($this->generateUrl($route, array('id' => $id))) |
|
| 181 | ->setMethod('DELETE') |
|
| 182 | ->getForm() |
|
| 183 | ; |
|
| 184 | } |
|
| 185 | ||
| 186 | } |
|
| 187 | ||