@@ 128-144 (lines=17) @@ | ||
125 | ]; |
|
126 | } |
|
127 | ||
128 | public function joinAction(Team $team, Player $me) |
|
129 | { |
|
130 | $this->requireLogin(); |
|
131 | if (!$me->isTeamless()) { |
|
132 | throw new ForbiddenException("You are already a member of a team"); |
|
133 | } elseif ($team->getStatus() != 'open') { |
|
134 | throw new ForbiddenException("This team is not accepting new members without an invitation"); |
|
135 | } |
|
136 | ||
137 | return $this->showConfirmationForm(function () use ($team, $me) { |
|
138 | $team->addMember($me->getId()); |
|
139 | Service::getDispatcher()->dispatch(Events::TEAM_JOIN, new Event\TeamJoinEvent($team, $me)); |
|
140 | ||
141 | return new RedirectResponse($team->getUrl()); |
|
142 | }, "Are you sure you want to join {$team->getEscapedName()}?", |
|
143 | "You are now a member of {$team->getName()}"); |
|
144 | } |
|
145 | ||
146 | public function kickAction(Team $team, Player $player, Player $me) |
|
147 | { |
|
@@ 168-185 (lines=18) @@ | ||
165 | "Player {$player->getUsername()} has been kicked from {$team->getName()}", "Kick"); |
|
166 | } |
|
167 | ||
168 | public function abandonAction(Team $team, Player $me) |
|
169 | { |
|
170 | if (!$team->isMember($me->getId())) { |
|
171 | throw new ForbiddenException("You are not a member of that team!"); |
|
172 | } |
|
173 | ||
174 | if ($team->getLeader()->isSameAs($me)) { |
|
175 | throw new ForbiddenException("You can't abandon the team you are leading."); |
|
176 | } |
|
177 | ||
178 | return $this->showConfirmationForm(function () use ($team, $me) { |
|
179 | $team->removeMember($me->getId()); |
|
180 | Service::getDispatcher()->dispatch(Events::TEAM_ABANDON, new Event\TeamAbandonEvent($team, $me)); |
|
181 | ||
182 | return new RedirectResponse($team->getUrl()); |
|
183 | }, "Are you sure you want to abandon {$team->getEscapedName()}?", |
|
184 | "You have left {$team->getName()}", "Abandon"); |
|
185 | } |
|
186 | ||
187 | public function assignLeaderAction(Team $team, Player $me, Player $player) |
|
188 | { |