public function abandonAction(Team $team, Player $me) { if (!$team->isMember($me->getId())) { throw new ForbiddenException("You are not a member of that team!"); } if ($team->getLeader()->getId() == $me->getId()) { throw new ForbiddenException("You can't abandon the team you are leading."); } return $this->showConfirmationForm(function () use($team, $me) { $team->removeMember($me->getId()); Service::getDispatcher()->dispatch(Events::TEAM_ABANDON, new Event\TeamAbandonEvent($team, $me)); return new RedirectResponse($team->getUrl()); }, "Are you sure you want to abandon {$team->getEscapedName()}?", "You have left {$team->getName()}", "Abandon"); }
/** * {@inheritDoc} */ public function notify($type) { $this->doNotify($this->team->getLeader(), $type); }
public function testTeamLeader() { $this->team = Team::createTeam("Sample Team", $this->player->getId(), "Sample Avatar Text", "Sample Description"); $team = new Team($this->team->getId()); $this->assertEquals($this->player->getId(), $team->getLeader()->getId()); }