| @@ 19-251 (lines=233) @@ | ||
| 16 | * |
|
| 17 | * @Route("/jedi") |
|
| 18 | */ |
|
| 19 | class JediController extends BackendController |
|
| 20 | { |
|
| 21 | /** |
|
| 22 | * Lists all Jedi entities. |
|
| 23 | * |
|
| 24 | * @Route("/", name="acme_app_jedi_index") |
|
| 25 | * @Method("GET") |
|
| 26 | * @Template() |
|
| 27 | */ |
|
| 28 | public function indexAction() |
|
| 29 | { |
|
| 30 | $em = $this->getDoctrine()->getManager(); |
|
| 31 | ||
| 32 | $entities = $em->getRepository('AcmeAppBundle:Jedi')->findAll(); |
|
| 33 | ||
| 34 | return [ |
|
| 35 | 'entities' => $entities, |
|
| 36 | ]; |
|
| 37 | } |
|
| 38 | ||
| 39 | /** |
|
| 40 | * Creates a new Jedi entity. |
|
| 41 | * |
|
| 42 | * @Route("/", name="acme_app_jedi_create") |
|
| 43 | * @Method("POST") |
|
| 44 | * @Template("AcmeAppBundle:Jedi:new.html.twig") |
|
| 45 | */ |
|
| 46 | public function createAction(Request $request) |
|
| 47 | { |
|
| 48 | $entity = new Jedi(); |
|
| 49 | $form = $this->createCreateForm($entity); |
|
| 50 | $form->handleRequest($request); |
|
| 51 | ||
| 52 | if ($form->isValid()) { |
|
| 53 | $em = $this->getDoctrine()->getManager(); |
|
| 54 | $em->persist($entity); |
|
| 55 | $em->flush(); |
|
| 56 | ||
| 57 | return $this->redirect($this->generateUrl('acme_app_jedi_index')); |
|
| 58 | } |
|
| 59 | ||
| 60 | return [ |
|
| 61 | 'entity' => $entity, |
|
| 62 | 'form' => $form->createView(), |
|
| 63 | ]; |
|
| 64 | } |
|
| 65 | ||
| 66 | /** |
|
| 67 | * Creates a form to create a Jedi entity. |
|
| 68 | * |
|
| 69 | * @param Jedi $entity The entity |
|
| 70 | * |
|
| 71 | * @return \Symfony\Component\Form\Form The form |
|
| 72 | */ |
|
| 73 | private function createCreateForm(Jedi $entity) |
|
| 74 | { |
|
| 75 | $form = $this->createForm(JediType::class, $entity, [ |
|
| 76 | 'action' => $this->generateUrl('acme_app_jedi_create'), |
|
| 77 | 'method' => 'POST', |
|
| 78 | ]); |
|
| 79 | ||
| 80 | $form->add('submit', 'submit', ['label' => 'acme.app.jedi.form.button.create']); |
|
| 81 | ||
| 82 | return $form; |
|
| 83 | } |
|
| 84 | ||
| 85 | /** |
|
| 86 | * Displays a form to create a new Jedi entity. |
|
| 87 | * |
|
| 88 | * @Route("/new", name="acme_app_jedi_new") |
|
| 89 | * @Method("GET") |
|
| 90 | * @Template() |
|
| 91 | */ |
|
| 92 | public function newAction() |
|
| 93 | { |
|
| 94 | $entity = new Jedi(); |
|
| 95 | $form = $this->createCreateForm($entity); |
|
| 96 | ||
| 97 | return [ |
|
| 98 | 'entity' => $entity, |
|
| 99 | 'form' => $form->createView(), |
|
| 100 | ]; |
|
| 101 | } |
|
| 102 | ||
| 103 | /** |
|
| 104 | * Finds and displays a Jedi entity. |
|
| 105 | * |
|
| 106 | * @Route("/{id}", name="acme_app_jedi_show") |
|
| 107 | * @Method("GET") |
|
| 108 | * @Template() |
|
| 109 | */ |
|
| 110 | public function showAction($id) |
|
| 111 | { |
|
| 112 | $em = $this->getDoctrine()->getManager(); |
|
| 113 | ||
| 114 | $entity = $em->getRepository('AcmeAppBundle:Jedi')->find($id); |
|
| 115 | ||
| 116 | if (!$entity) { |
|
| 117 | throw $this->createNotFoundException('Unable to find Jedi entity.'); |
|
| 118 | } |
|
| 119 | ||
| 120 | $deleteForm = $this->createDeleteForm($id); |
|
| 121 | ||
| 122 | return [ |
|
| 123 | 'entity' => $entity, |
|
| 124 | 'delete_form' => $deleteForm->createView(), |
|
| 125 | ]; |
|
| 126 | } |
|
| 127 | ||
| 128 | /** |
|
| 129 | * Displays a form to edit an existing Jedi entity. |
|
| 130 | * |
|
| 131 | * @Route("/{id}/edit", name="acme_app_jedi_edit") |
|
| 132 | * @Method("GET") |
|
| 133 | * @Template() |
|
| 134 | */ |
|
| 135 | public function editAction($id) |
|
| 136 | { |
|
| 137 | $em = $this->getDoctrine()->getManager(); |
|
| 138 | ||
| 139 | $entity = $em->getRepository('AcmeAppBundle:Jedi')->find($id); |
|
| 140 | ||
| 141 | if (!$entity) { |
|
| 142 | throw $this->createNotFoundException('Unable to find Jedi entity.'); |
|
| 143 | } |
|
| 144 | ||
| 145 | $editForm = $this->createEditForm($entity); |
|
| 146 | $deleteForm = $this->createDeleteForm($id); |
|
| 147 | ||
| 148 | return [ |
|
| 149 | 'entity' => $entity, |
|
| 150 | 'edit_form' => $editForm->createView(), |
|
| 151 | 'delete_form' => $deleteForm->createView(), |
|
| 152 | ]; |
|
| 153 | } |
|
| 154 | ||
| 155 | /** |
|
| 156 | * Creates a form to edit a Jedi entity. |
|
| 157 | * |
|
| 158 | * @param Jedi $entity The entity |
|
| 159 | * |
|
| 160 | * @return \Symfony\Component\Form\Form The form |
|
| 161 | */ |
|
| 162 | private function createEditForm(Jedi $entity) |
|
| 163 | { |
|
| 164 | $form = $this->createForm(JediType::class, $entity, [ |
|
| 165 | 'action' => $this->generateUrl('acme_app_jedi_update', ['id' => $entity->getId()]), |
|
| 166 | 'method' => 'PUT', |
|
| 167 | ]); |
|
| 168 | ||
| 169 | $form->add('submit', 'submit', ['label' => 'acme.app.jedi.form.button.update']); |
|
| 170 | ||
| 171 | return $form; |
|
| 172 | } |
|
| 173 | ||
| 174 | /** |
|
| 175 | * Edits an existing Jedi entity. |
|
| 176 | * |
|
| 177 | * @Route("/{id}", name="acme_app_jedi_update") |
|
| 178 | * @Method("PUT") |
|
| 179 | * @Template("AcmeAppBundle:Jedi:edit.html.twig") |
|
| 180 | */ |
|
| 181 | public function updateAction(Request $request, $id) |
|
| 182 | { |
|
| 183 | $em = $this->getDoctrine()->getManager(); |
|
| 184 | ||
| 185 | $entity = $em->getRepository('AcmeAppBundle:Jedi')->find($id); |
|
| 186 | ||
| 187 | if (!$entity) { |
|
| 188 | throw $this->createNotFoundException('Unable to find Jedi entity.'); |
|
| 189 | } |
|
| 190 | ||
| 191 | $deleteForm = $this->createDeleteForm($id); |
|
| 192 | $editForm = $this->createEditForm($entity); |
|
| 193 | $editForm->handleRequest($request); |
|
| 194 | ||
| 195 | if ($editForm->isValid()) { |
|
| 196 | $em->flush(); |
|
| 197 | ||
| 198 | return $this->redirect($this->generateUrl('acme_app_jedi_index')); |
|
| 199 | } |
|
| 200 | ||
| 201 | return [ |
|
| 202 | 'entity' => $entity, |
|
| 203 | 'edit_form' => $editForm->createView(), |
|
| 204 | 'delete_form' => $deleteForm->createView(), |
|
| 205 | ]; |
|
| 206 | } |
|
| 207 | ||
| 208 | /** |
|
| 209 | * Deletes a Jedi entity. |
|
| 210 | * |
|
| 211 | * @Route("/{id}", name="acme_app_jedi_delete") |
|
| 212 | * @Method("DELETE") |
|
| 213 | */ |
|
| 214 | public function deleteAction(Request $request, $id) |
|
| 215 | { |
|
| 216 | $form = $this->createDeleteForm($id); |
|
| 217 | $form->handleRequest($request); |
|
| 218 | ||
| 219 | if ($form->isValid()) { |
|
| 220 | $em = $this->getDoctrine()->getManager(); |
|
| 221 | $entity = $em->getRepository('AcmeAppBundle:Jedi')->find($id); |
|
| 222 | ||
| 223 | if (!$entity) { |
|
| 224 | throw $this->createNotFoundException('Unable to find Jedi entity.'); |
|
| 225 | } |
|
| 226 | ||
| 227 | $em->remove($entity); |
|
| 228 | $em->flush(); |
|
| 229 | } |
|
| 230 | ||
| 231 | return $this->redirect($this->generateUrl('acme_app_jedi_index')); |
|
| 232 | } |
|
| 233 | ||
| 234 | /** |
|
| 235 | * Creates a form to delete a Jedi entity by id. |
|
| 236 | * |
|
| 237 | * @param mixed $id The entity id |
|
| 238 | * |
|
| 239 | * @return \Symfony\Component\Form\Form The form |
|
| 240 | */ |
|
| 241 | private function createDeleteForm($id) |
|
| 242 | { |
|
| 243 | return $this->createFormBuilder(null, [ |
|
| 244 | 'translation_domain' => 'victoire', |
|
| 245 | ]) |
|
| 246 | ->setAction($this->generateUrl('acme_app_jedi_delete', ['id' => $id])) |
|
| 247 | ->setMethod('DELETE') |
|
| 248 | ->add('submit', 'submit', ['label' => 'acme.app.jedi.form.button.delete']) |
|
| 249 | ->getForm(); |
|
| 250 | } |
|
| 251 | } |
|
| 252 | ||
| @@ 19-251 (lines=233) @@ | ||
| 16 | * |
|
| 17 | * @Route("/spaceship") |
|
| 18 | */ |
|
| 19 | class SpaceShipController extends BackendController |
|
| 20 | { |
|
| 21 | /** |
|
| 22 | * Lists all SpaceShip entities. |
|
| 23 | * |
|
| 24 | * @Route("/", name="acme_app_spaceship_index") |
|
| 25 | * @Method("GET") |
|
| 26 | * @Template() |
|
| 27 | */ |
|
| 28 | public function indexAction() |
|
| 29 | { |
|
| 30 | $em = $this->getDoctrine()->getManager(); |
|
| 31 | ||
| 32 | $entities = $em->getRepository('AcmeAppBundle:SpaceShip')->findAll(); |
|
| 33 | ||
| 34 | return [ |
|
| 35 | 'entities' => $entities, |
|
| 36 | ]; |
|
| 37 | } |
|
| 38 | ||
| 39 | /** |
|
| 40 | * Creates a new SpaceShip entity. |
|
| 41 | * |
|
| 42 | * @Route("/", name="acme_app_spaceship_create") |
|
| 43 | * @Method("POST") |
|
| 44 | * @Template("AcmeAppBundle:SpaceShip:new.html.twig") |
|
| 45 | */ |
|
| 46 | public function createAction(Request $request) |
|
| 47 | { |
|
| 48 | $entity = new SpaceShip(); |
|
| 49 | $form = $this->createCreateForm($entity); |
|
| 50 | $form->handleRequest($request); |
|
| 51 | ||
| 52 | if ($form->isValid()) { |
|
| 53 | $em = $this->getDoctrine()->getManager(); |
|
| 54 | $em->persist($entity); |
|
| 55 | $em->flush(); |
|
| 56 | ||
| 57 | return $this->redirect($this->generateUrl('acme_app_spaceship_index')); |
|
| 58 | } |
|
| 59 | ||
| 60 | return [ |
|
| 61 | 'entity' => $entity, |
|
| 62 | 'form' => $form->createView(), |
|
| 63 | ]; |
|
| 64 | } |
|
| 65 | ||
| 66 | /** |
|
| 67 | * Creates a form to create a SpaceShip entity. |
|
| 68 | * |
|
| 69 | * @param SpaceShip $entity The entity |
|
| 70 | * |
|
| 71 | * @return \Symfony\Component\Form\Form The form |
|
| 72 | */ |
|
| 73 | private function createCreateForm(SpaceShip $entity) |
|
| 74 | { |
|
| 75 | $form = $this->createForm(SpaceShipType::class, $entity, [ |
|
| 76 | 'action' => $this->generateUrl('acme_app_spaceship_create'), |
|
| 77 | 'method' => 'POST', |
|
| 78 | ]); |
|
| 79 | ||
| 80 | $form->add('submit', 'submit', ['label' => 'acme.app.spaceship.form.button.create']); |
|
| 81 | ||
| 82 | return $form; |
|
| 83 | } |
|
| 84 | ||
| 85 | /** |
|
| 86 | * Displays a form to create a new SpaceShip entity. |
|
| 87 | * |
|
| 88 | * @Route("/new", name="acme_app_spaceship_new") |
|
| 89 | * @Method("GET") |
|
| 90 | * @Template() |
|
| 91 | */ |
|
| 92 | public function newAction() |
|
| 93 | { |
|
| 94 | $entity = new SpaceShip(); |
|
| 95 | $form = $this->createCreateForm($entity); |
|
| 96 | ||
| 97 | return [ |
|
| 98 | 'entity' => $entity, |
|
| 99 | 'form' => $form->createView(), |
|
| 100 | ]; |
|
| 101 | } |
|
| 102 | ||
| 103 | /** |
|
| 104 | * Finds and displays a SpaceShip entity. |
|
| 105 | * |
|
| 106 | * @Route("/{id}", name="acme_app_spaceship_show") |
|
| 107 | * @Method("GET") |
|
| 108 | * @Template() |
|
| 109 | */ |
|
| 110 | public function showAction($id) |
|
| 111 | { |
|
| 112 | $em = $this->getDoctrine()->getManager(); |
|
| 113 | ||
| 114 | $entity = $em->getRepository('AcmeAppBundle:SpaceShip')->find($id); |
|
| 115 | ||
| 116 | if (!$entity) { |
|
| 117 | throw $this->createNotFoundException('Unable to find SpaceShip entity.'); |
|
| 118 | } |
|
| 119 | ||
| 120 | $deleteForm = $this->createDeleteForm($id); |
|
| 121 | ||
| 122 | return [ |
|
| 123 | 'entity' => $entity, |
|
| 124 | 'delete_form' => $deleteForm->createView(), |
|
| 125 | ]; |
|
| 126 | } |
|
| 127 | ||
| 128 | /** |
|
| 129 | * Displays a form to edit an existing SpaceShip entity. |
|
| 130 | * |
|
| 131 | * @Route("/{id}/edit", name="acme_app_spaceship_edit") |
|
| 132 | * @Method("GET") |
|
| 133 | * @Template() |
|
| 134 | */ |
|
| 135 | public function editAction($id) |
|
| 136 | { |
|
| 137 | $em = $this->getDoctrine()->getManager(); |
|
| 138 | ||
| 139 | $entity = $em->getRepository('AcmeAppBundle:SpaceShip')->find($id); |
|
| 140 | ||
| 141 | if (!$entity) { |
|
| 142 | throw $this->createNotFoundException('Unable to find SpaceShip entity.'); |
|
| 143 | } |
|
| 144 | ||
| 145 | $editForm = $this->createEditForm($entity); |
|
| 146 | $deleteForm = $this->createDeleteForm($id); |
|
| 147 | ||
| 148 | return [ |
|
| 149 | 'entity' => $entity, |
|
| 150 | 'form' => $editForm->createView(), |
|
| 151 | 'delete_form' => $deleteForm->createView(), |
|
| 152 | ]; |
|
| 153 | } |
|
| 154 | ||
| 155 | /** |
|
| 156 | * Creates a form to edit a SpaceShip entity. |
|
| 157 | * |
|
| 158 | * @param SpaceShip $entity The entity |
|
| 159 | * |
|
| 160 | * @return \Symfony\Component\Form\Form The form |
|
| 161 | */ |
|
| 162 | private function createEditForm(SpaceShip $entity) |
|
| 163 | { |
|
| 164 | $form = $this->createForm(SpaceShipType::class, $entity, [ |
|
| 165 | 'action' => $this->generateUrl('acme_app_spaceship_update', ['id' => $entity->getId()]), |
|
| 166 | 'method' => 'PUT', |
|
| 167 | ]); |
|
| 168 | ||
| 169 | $form->add('submit', 'submit', ['label' => 'acme.app.spaceship.form.button.update']); |
|
| 170 | ||
| 171 | return $form; |
|
| 172 | } |
|
| 173 | ||
| 174 | /** |
|
| 175 | * Edits an existing SpaceShip entity. |
|
| 176 | * |
|
| 177 | * @Route("/{id}", name="acme_app_spaceship_update") |
|
| 178 | * @Method("PUT") |
|
| 179 | * @Template("AcmeAppBundle:SpaceShip:edit.html.twig") |
|
| 180 | */ |
|
| 181 | public function updateAction(Request $request, $id) |
|
| 182 | { |
|
| 183 | $em = $this->getDoctrine()->getManager(); |
|
| 184 | ||
| 185 | $entity = $em->getRepository('AcmeAppBundle:SpaceShip')->find($id); |
|
| 186 | ||
| 187 | if (!$entity) { |
|
| 188 | throw $this->createNotFoundException('Unable to find SpaceShip entity.'); |
|
| 189 | } |
|
| 190 | ||
| 191 | $deleteForm = $this->createDeleteForm($id); |
|
| 192 | $editForm = $this->createEditForm($entity); |
|
| 193 | $editForm->handleRequest($request); |
|
| 194 | ||
| 195 | if ($editForm->isValid()) { |
|
| 196 | $em->flush(); |
|
| 197 | ||
| 198 | return $this->redirect($this->generateUrl('acme_app_spaceship_index')); |
|
| 199 | } |
|
| 200 | ||
| 201 | return [ |
|
| 202 | 'entity' => $entity, |
|
| 203 | 'form' => $editForm->createView(), |
|
| 204 | 'delete_form' => $deleteForm->createView(), |
|
| 205 | ]; |
|
| 206 | } |
|
| 207 | ||
| 208 | /** |
|
| 209 | * Deletes a SpaceShip entity. |
|
| 210 | * |
|
| 211 | * @Route("/{id}", name="acme_app_spaceship_delete") |
|
| 212 | * @Method("DELETE") |
|
| 213 | */ |
|
| 214 | public function deleteAction(Request $request, $id) |
|
| 215 | { |
|
| 216 | $form = $this->createDeleteForm($id); |
|
| 217 | $form->handleRequest($request); |
|
| 218 | ||
| 219 | if ($form->isValid()) { |
|
| 220 | $em = $this->getDoctrine()->getManager(); |
|
| 221 | $entity = $em->getRepository('AcmeAppBundle:SpaceShip')->find($id); |
|
| 222 | ||
| 223 | if (!$entity) { |
|
| 224 | throw $this->createNotFoundException('Unable to find SpaceShip entity.'); |
|
| 225 | } |
|
| 226 | ||
| 227 | $em->remove($entity); |
|
| 228 | $em->flush(); |
|
| 229 | } |
|
| 230 | ||
| 231 | return $this->redirect($this->generateUrl('acme_app_spaceship_index')); |
|
| 232 | } |
|
| 233 | ||
| 234 | /** |
|
| 235 | * Creates a form to delete a SpaceShip entity by id. |
|
| 236 | * |
|
| 237 | * @param mixed $id The entity id |
|
| 238 | * |
|
| 239 | * @return \Symfony\Component\Form\Form The form |
|
| 240 | */ |
|
| 241 | private function createDeleteForm($id) |
|
| 242 | { |
|
| 243 | return $this->createFormBuilder(null, [ |
|
| 244 | 'translation_domain' => 'victoire', |
|
| 245 | ]) |
|
| 246 | ->setAction($this->generateUrl('acme_app_spaceship_delete', ['id' => $id])) |
|
| 247 | ->setMethod('DELETE') |
|
| 248 | ->add('submit', 'submit', ['label' => 'acme.app.spaceship.form.button.delete']) |
|
| 249 | ->getForm(); |
|
| 250 | } |
|
| 251 | } |
|
| 252 | ||