当前位置: 首页>>代码示例>>PHP>>正文


PHP AphrontRequest::getRemoteAddr方法代码示例

本文整理汇总了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())));
 }
开发者ID:shrimpma,项目名称:phabricator,代码行数:24,代码来源:PonderAnswerSaveController.php

示例2: newFromRequest

 public static function newFromRequest(AphrontRequest $request)
 {
     return self::newForSource(self::SOURCE_WEB, array('ip' => $request->getRemoteAddr()));
 }
开发者ID:fengshao0907,项目名称:phabricator,代码行数:4,代码来源:PhabricatorContentSource.php


注:本文中的AphrontRequest::getRemoteAddr方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。