本文整理汇总了PHP中AphrontRequest::getRemoteAddr方法的典型用法代码示例。如果您正苦于以下问题:PHP AphrontRequest::getRemoteAddr方法的具体用法?PHP AphrontRequest::getRemoteAddr怎么用?PHP AphrontRequest::getRemoteAddr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AphrontRequest
的用法示例。
在下文中一共展示了AphrontRequest::getRemoteAddr方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handleRequest
public function handleRequest(AphrontRequest $request)
{
$viewer = $request->getViewer();
if (!$request->isFormPost()) {
return new Aphront400Response();
}
$question_id = $request->getInt('question_id');
$question = id(new PonderQuestionQuery())->setViewer($viewer)->withIDs(array($question_id))->needAnswers(true)->executeOne();
if (!$question) {
return new Aphront404Response();
}
$answer = $request->getStr('answer');
if (!strlen(trim($answer))) {
$dialog = id(new AphrontDialogView())->setUser($viewer)->setTitle(pht('Empty Answer'))->appendChild(phutil_tag('p', array(), pht('Your answer must not be empty.')))->addCancelButton('/Q' . $question_id);
return id(new AphrontDialogResponse())->setDialog($dialog);
}
$content_source = PhabricatorContentSource::newForSource(PhabricatorContentSource::SOURCE_WEB, array('ip' => $request->getRemoteAddr()));
$res = id(new PonderAnswer())->setAuthorPHID($viewer->getPHID())->setQuestionID($question->getID())->setContent($answer)->setVoteCount(0)->setContentSource($content_source);
$xactions = array();
$xactions[] = id(new PonderQuestionTransaction())->setTransactionType(PonderQuestionTransaction::TYPE_ANSWERS)->setNewValue(array('+' => array(array('answer' => $res))));
$editor = id(new PonderQuestionEditor())->setActor($viewer)->setContentSourceFromRequest($request);
$editor->applyTransactions($question, $xactions);
return id(new AphrontRedirectResponse())->setURI(id(new PhutilURI('/Q' . $question->getID())));
}
示例2: newFromRequest
public static function newFromRequest(AphrontRequest $request)
{
return self::newForSource(self::SOURCE_WEB, array('ip' => $request->getRemoteAddr()));
}