| @@ 42-61 (lines=20) @@ | ||
| 39 | * |
|
| 40 | * @return RedirectResponse|Response |
|
| 41 | */ |
|
| 42 | public function newAction(Request $request) |
|
| 43 | { |
|
| 44 | $questFactory = $this->get('badger.game.quest.factory'); |
|
| 45 | $quest = $questFactory->create(); |
|
| 46 | ||
| 47 | $form = $this->createForm(QuestType::class, $quest); |
|
| 48 | $form->handleRequest($request); |
|
| 49 | ||
| 50 | if ($form->isSubmitted() && $form->isValid()) { |
|
| 51 | $questSaver = $this->get('badger.game.saver.quest'); |
|
| 52 | $questSaver->save($quest); |
|
| 53 | ||
| 54 | return $this->redirectToRoute('admin_quest_show', ['id' => $quest->getId()]); |
|
| 55 | } |
|
| 56 | ||
| 57 | return $this->render('@Game/quests/new.html.twig', [ |
|
| 58 | 'quest' => $quest, |
|
| 59 | 'form' => $form->createView() |
|
| 60 | ]); |
|
| 61 | } |
|
| 62 | ||
| 63 | /** |
|
| 64 | * Finds and displays a Quest entity. |
|
| @@ 89-106 (lines=18) @@ | ||
| 86 | * |
|
| 87 | * @return RedirectResponse|Response |
|
| 88 | */ |
|
| 89 | public function editAction(Request $request, $id) |
|
| 90 | { |
|
| 91 | $quest = $this->get('badger.game.repository.quest')->find($id); |
|
| 92 | $editForm = $this->createForm(QuestType::class, $quest); |
|
| 93 | $editForm->handleRequest($request); |
|
| 94 | ||
| 95 | if ($editForm->isSubmitted() && $editForm->isValid()) { |
|
| 96 | $questSaver = $this->get('badger.game.saver.quest'); |
|
| 97 | $questSaver->save($quest); |
|
| 98 | ||
| 99 | return $this->redirectToRoute('admin_quest_edit', ['id' => $quest->getId()]); |
|
| 100 | } |
|
| 101 | ||
| 102 | return $this->render('@Game/quests/edit.html.twig', [ |
|
| 103 | 'quest' => $quest, |
|
| 104 | 'edit_form' => $editForm->createView(), |
|
| 105 | ]); |
|
| 106 | } |
|
| 107 | ||
| 108 | /** |
|
| 109 | * Deletes a Quest entity. |
|
| @@ 39-59 (lines=21) @@ | ||
| 36 | * |
|
| 37 | * @return RedirectResponse|Response |
|
| 38 | */ |
|
| 39 | public function newAction(Request $request) |
|
| 40 | { |
|
| 41 | $tagFactory = $this->get('badger.tags.tag.factory'); |
|
| 42 | $tag = $tagFactory->create(); |
|
| 43 | ||
| 44 | $form = $this->createForm('Badger\Bundle\GameBundle\Form\TagType', $tag); |
|
| 45 | $form->remove('createdAt'); |
|
| 46 | $form->handleRequest($request); |
|
| 47 | ||
| 48 | if ($form->isSubmitted() && $form->isValid()) { |
|
| 49 | $tagSaver = $this->get('badger.tags.saver.tag'); |
|
| 50 | $tagSaver->save($tag); |
|
| 51 | ||
| 52 | return $this->redirectToRoute('admin_tag_show', ['id' => $tag->getId()]); |
|
| 53 | } |
|
| 54 | ||
| 55 | return $this->render('@Tag/tag/new.html.twig', [ |
|
| 56 | 'tag' => $tag, |
|
| 57 | 'form' => $form->createView(), |
|
| 58 | ]); |
|
| 59 | } |
|
| 60 | ||
| 61 | /** |
|
| 62 | * Finds and displays a Tag entity. |
|
| @@ 86-103 (lines=18) @@ | ||
| 83 | * |
|
| 84 | * @return RedirectResponse|Response |
|
| 85 | */ |
|
| 86 | public function editAction(Request $request, Tag $tag) |
|
| 87 | { |
|
| 88 | $editForm = $this->createForm('Badger\Bundle\GameBundle\Form\TagType', $tag); |
|
| 89 | $editForm->remove('createdAt'); |
|
| 90 | $editForm->handleRequest($request); |
|
| 91 | ||
| 92 | if ($editForm->isSubmitted() && $editForm->isValid()) { |
|
| 93 | $tagSaver = $this->get('badger.tags.saver.tag'); |
|
| 94 | $tagSaver->save($tag); |
|
| 95 | ||
| 96 | return $this->redirectToRoute('admin_tag_edit', ['id' => $tag->getId()]); |
|
| 97 | } |
|
| 98 | ||
| 99 | return $this->render('@Tag/tag/edit.html.twig', [ |
|
| 100 | 'tag' => $tag, |
|
| 101 | 'edit_form' => $editForm->createView(), |
|
| 102 | ]); |
|
| 103 | } |
|
| 104 | ||
| 105 | /** |
|
| 106 | * Deletes a Tag entity. |
|