public function teamRefreshAction(Player $me, Conversation $conversation) { $team = $me->getTeam(); if (!$team->isValid()) { throw new ForbiddenException("You are not a member of a team."); } $missing = $conversation->getMissingTeamMembers($team); if (empty($missing)) { throw new ForbiddenException("All members of the specified team are already part of that conversation."); } $names = array(); foreach ($missing as $player) { $names[] = $player->getEscapedUsername(); } $names = implode(', ', $names); return $this->showConfirmationForm(function () use($conversation, $missing, $team) { $conversation->addMember($team); // does all the hard work $event = new ConversationJoinEvent($conversation, $missing); Service::getDispatcher()->dispatch(Events::CONVERSATION_JOIN, $event); return new RedirectResponse($conversation->getURL()); }, "Are you sure you want to invite {$names} from {$team->getEscapedName()} to that conversation?"); }