本文整理汇总了PHP中Player::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Player::get方法的具体用法?PHP Player::get怎么用?PHP Player::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Player
的用法示例。
在下文中一共展示了Player::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: assignResult
/**
* {@inheritdoc}
*/
protected function assignResult($key)
{
$this->name = $key['name'];
$this->owner = Player::get($key['owner']);
$this->key = $key['key'];
$this->status = $key['status'];
}
示例2: view
public function view(SS_HTTPRequest $request)
{
$params = $request->params();
$game_id = $params['ID'];
$game = Game::get()->filter('ID', $game_id)->first();
$teams = $game->Teams();
$allTeams = array();
foreach ($teams as $team) {
$teamArr = array();
$player_one = Player::get()->filter('ID', $team->PlayerOne)->first();
$player_two = Player::get()->filter('ID', $team->PlayerTwo)->first();
$teamArr['Names'] = $player_one->Name . ' & ' . $player_two->Name;
$teamArr['GamesPlayed'] = $team->getGamesPlayed();
$teamArr['TeamID'] = $team->ID;
if ($allTeams == array()) {
$allTeams['TeamOne'] = $teamArr;
} else {
$allTeams['TeamTwo'] = $teamArr;
}
}
$link = $this->Link();
$data = new ArrayData(array('Teams' => $allTeams, 'ParentLink' => $link, 'Winner' => $game->Winner, 'Score' => $game->ScoreTeamOne . '-' . $game->ScoreTeamTwo));
if ($data->getField('Teams') == array()) {
$data = new ArrayData(array('Content' => 'There are no teams assigned to this game.', 'AddNewTeam' => '<a href="' . $link . 'assignteams/' . $game_id . '" class="btn btn-success">Assign a Team to this game</a>', 'ParentLink' => $this->Link()));
Session::set('GameID', $game_id);
}
return $data->renderWith(array('Game', 'Page'));
}
示例3: newTeamForm
public function newTeamForm()
{
$players = Player::get();
$playerOne = DropdownField::create('PlayerOne', 'Player One', $players->map('ID', 'FirstName'));
$playerTwo = DropdownField::create('PlayerTwo', 'Player Two', $players->map('ID', 'FirstName'));
$fields = new FieldList($playerOne, $playerTwo);
$actions = new FieldList(FormAction::create("doAddTeam")->setTitle("Add Team"));
$required = new RequiredFields('PlayerOne', 'PlayerTwo');
$form = Form::create($this, 'doAddTeam', $fields, $actions, $required);
$form->setTemplate('forms/NewTeamForm');
return $form;
}
示例4: doAddPlayer
public function doAddPlayer($data, Form $form)
{
$player_exists = Player::get()->filter(array('FirstName' => $data['FirstName'], 'Surname' => $data['Surname']))->count() > 0 ? true : false;
if ($player_exists) {
// todo
// add error message because player already exists
return $this->redirectBack();
} else {
$player = Player::create();
$player->FirstName = $data['FirstName'];
$player->Surname = $data['Surname'];
$player->write();
$redirectLink = $this->Link() . '?success=1';
return $this->redirect($redirectLink);
}
}
示例5: getLastEditor
/**
* Get the last editor of the post
* @return Player A Player object of the last editor
*/
public function getLastEditor()
{
return Player::get($this->editor);
}
示例6: getMe
/**
* Gets the currently logged in player
* @return Player
*/
public static function getMe()
{
return Player::get(self::getRequest()->getSession()->get('playerId'));
}
示例7: getAuthor
/**
* Gets the creator of the message
* @return Player An object representing the message's author
*/
public function getAuthor()
{
return Player::get($this->player_from);
}
示例8: getTeam
/**
* Queries the database to get the team which a group of players belong to
*
* @param int[] $players The IDs of players
* @return Team The team
*/
private function getTeam($players)
{
$team = null;
foreach ($players as $id) {
$player = Player::get($id);
if ($player->isTeamless()) {
return Team::invalid();
} elseif ($team == null) {
$team = $player->getTeam();
} elseif ($team->getId() != $player->getTeam()->getId()) {
// This player is on a different team from the previous player!
return Team::invalid();
}
}
return $team;
}
示例9: getEnteredBy
/**
* Get the user who entered the match
* @return Player
*/
public function getEnteredBy()
{
return Player::get($this->entered_by);
}
示例10: unserialize
/**
* {@inheritdoc}
*/
public function unserialize($data)
{
$data = unserialize($data);
$this->__construct(\Team::get($data['team']), \Player::get($data['deleter']));
}
示例11: getFromUsername
/**
* Get a single player by their username
*
* @param string $username The username to look for
* @return Player
*/
public static function getFromUsername($username)
{
return Player::get(self::fetchIdFrom($username, 'username', 's'));
}
示例12: sendEmails
/**
* Send emails to a list of recipients
*
* @param string $subject The subject of the messages
* @param int[] $recipients The IDs of the players to which the messages will be sent
* @param string $template The twig template name for the e-mail body
* @param array $params Any extra parameters to pass to twig
* @return void
*/
public function sendEmails($subject, $recipients, $template, $params = array())
{
if (!$this->from) {
return;
}
$message = \Swift_Message::newInstance()->setSubject($subject)->setFrom(array($this->from => $this->siteTitle))->setBody($this->twig->render("Email/{$template}.txt.twig", $params))->addPart($this->twig->render("Email/{$template}.html.twig", $params), 'text/html');
foreach ($recipients as $recipient) {
$recipient = \Player::get($recipient);
if (!$recipient->isVerified()) {
continue;
}
$message->setTo($recipient->getEmailAddress());
$this->mailer->send($message);
}
}
示例13: getPlayer
/**
* Get the visiting player
* @return Player
*/
public function getPlayer()
{
return Player::get($this->player);
}
示例14: getSentBy
/**
* Get the sender of the invite
*
* @return Player
*/
public function getSentBy()
{
return Player::get($this->sent_by);
}
示例15: getOwner
/**
* Get the owner of the server
* @return Player
*/
public function getOwner()
{
return Player::get($this->owner);
}