| @@ 58-70 (lines=13) @@ | ||
| 55 | if ($form->isSubmitted()) { |
|
| 56 | $this->validate($form); |
|
| 57 | ||
| 58 | if ($form->isValid()) { |
|
| 59 | $clickedButton = $form->getClickedButton()->getName(); |
|
| 60 | ||
| 61 | if ($clickedButton === 'submit') { |
|
| 62 | $invitation = $creator->enter($form); |
|
| 63 | ||
| 64 | self::getFlashBag()->add('success', sprintf('"%s" has been invited to "%s."', $invitation->getInvitedPlayer()->getName(), $team->getName())); |
|
| 65 | ||
| 66 | return $this->redirectTo($team); |
|
| 67 | } |
|
| 68 | ||
| 69 | return (new RedirectResponse($this->getPreviousURL())); |
|
| 70 | } |
|
| 71 | } else { |
|
| 72 | $form->get('invited_player')->setData($player); |
|
| 73 | } |
|
| @@ 104-120 (lines=17) @@ | ||
| 101 | $creator = new TeamRestorationFormCreator($team, $me, $this); |
|
| 102 | $form = $creator->create()->handleRequest(self::getRequest()); |
|
| 103 | ||
| 104 | if ($form->isSubmitted()) { |
|
| 105 | $this->validate($form); |
|
| 106 | ||
| 107 | if ($form->isValid()) { |
|
| 108 | $clickedButton = $form->getClickedButton()->getName(); |
|
| 109 | ||
| 110 | if ($clickedButton === 'submit') { |
|
| 111 | $model = $creator->enter($form); |
|
| 112 | ||
| 113 | self::getFlashBag()->add('success', "\"{$model->getName()}\" has been restored."); |
|
| 114 | ||
| 115 | return $this->redirectTo($model); |
|
| 116 | } |
|
| 117 | ||
| 118 | return (new RedirectResponse($this->getPreviousURL())); |
|
| 119 | } |
|
| 120 | } |
|
| 121 | ||
| 122 | return [ |
|
| 123 | 'form' => $form->createView(), |
|