本文整理汇总了PHP中Player::canEdit方法的典型用法代码示例。如果您正苦于以下问题:PHP Player::canEdit方法的具体用法?PHP Player::canEdit怎么用?PHP Player::canEdit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Player
的用法示例。
在下文中一共展示了Player::canEdit方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: editAction
public function editAction(Player $player, Player $me)
{
if (!$me->canEdit($player)) {
throw new ForbiddenException("You are not allowed to edit other players");
}
$params = array('me' => $player, 'self' => false);
return $this->forward('edit', $params, 'Profile');
}
示例2: showAction
public function showAction(Server $server, Player $me, Request $request)
{
if ($server->staleInfo()) {
$server->forceUpdate();
}
if ($request->get('forced') && $me->canEdit($server)) {
$server->forceUpdate();
}
return array("server" => $server);
}
示例3: inviteAction
public function inviteAction(Team $team, Player $player, Player $me)
{
if (!$me->canEdit($team)) {
throw new ForbiddenException("You are not allowed to invite a player to that team!");
} elseif ($team->isMember($player->getId())) {
throw new ForbiddenException("The specified player is already a member of that team.");
} elseif (Invitation::hasOpenInvitation($player->getId(), $team->getId())) {
throw new ForbiddenException("This player has already been invited to join the team.");
}
return $this->showConfirmationForm(function () use($team, $player, $me) {
$invite = Invitation::sendInvite($player->getId(), $me->getId(), $team->getId());
Service::getDispatcher()->dispatch(Events::TEAM_INVITE, new TeamInviteEvent($invite));
return new RedirectResponse($team->getUrl());
}, "Are you sure you want to invite {$player->getEscapedUsername()} to {$team->getEscapedName()}?", "Player {$player->getUsername()} has been invited to {$team->getName()}");
}
示例4: recalculateAction
public function recalculateAction(Player $me, $match)
{
$match = Match::get($match);
// get a match even if it's deleted
if (!$me->canEdit($match)) {
throw new ForbiddenException("You are not allowed to edit that match.");
}
return $this->showConfirmationForm(function () use($match) {
$response = new StreamedResponse();
$response->headers->set('Content-Type', 'text/plain');
$response->setCallback(function () use($match) {
$this->recalculate($match);
});
$response->send();
}, "Do you want to recalculate ELO history for all teams and matches after the specified match?", "ELO history recalculated", "Recalculate ELOs", function () use($match) {
if ($match->isDeleted()) {
return new RedirectResponse($match->getURL('list'));
}
return new RedirectResponse($match->getURL('show'));
}, "Match/recalculate.html.twig", $noButton = true);
}
示例5: canEdit
/**
* Find whether a player can edit a model
*
* @param Player $player The player who wants to delete the model
* @param PermissionModel $model The model which will be edited
* @return bool
*/
protected function canEdit($player, $model)
{
return $player->canEdit($model);
}
示例6: teamLeaveAction
public function teamLeaveAction(Player $me, Conversation $conversation)
{
$team = $me->getTeam();
if (!$me->canEdit($team)) {
throw new ForbiddenException("You are not allowed to remove your team from this conversation.");
} elseif (!$conversation->isMember($team)) {
throw new ForbiddenException("That team is not participating in this conversation.");
}
return $this->showConfirmationForm(function () use($conversation, $team) {
$conversation->removeMember($team);
$event = new ConversationAbandonEvent($conversation, $team);
Service::getDispatcher()->dispatch(Events::CONVERSATION_ABANDON, $event);
return new RedirectResponse($conversation->getURL());
}, "Are you sure you want to remove {$team->getEscapedName()} from this conversation?", "Your team is no longer participating in that conversation.", "Remove team");
}
示例7: assertCanEdit
/**
* Make sure that a player can edit a team
*
* Throws an exception if a player is not an admin or the leader of a team
* @throws HTTPException
* @param Player $player The player to test
* @param Team $team The team
* @param string $message The error message to show
* @return void
*/
private function assertCanEdit(Player $player, Team $team, $message = "You are not allowed to edit that team")
{
if (!$player->canEdit($team)) {
throw new ForbiddenException($message);
}
}