[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/ponder/controller/ -> PonderQuestionCommentController.php (source)

   1  <?php
   2  
   3  final class PonderQuestionCommentController extends PonderController {
   4  
   5    private $id;
   6  
   7    public function willProcessRequest(array $data) {
   8      $this->id = $data['id'];
   9    }
  10  
  11    public function processRequest() {
  12      $request = $this->getRequest();
  13      $viewer = $request->getUser();
  14  
  15      if (!$request->isFormPost()) {
  16        return new Aphront400Response();
  17      }
  18  
  19      $question = id(new PonderQuestionQuery())
  20        ->setViewer($viewer)
  21        ->withIDs(array($this->id))
  22        ->executeOne();
  23      if (!$question) {
  24        return new Aphront404Response();
  25      }
  26  
  27      $is_preview = $request->isPreviewRequest();
  28  //    $draft = PhabricatorDraft::buildFromRequest($request);
  29  
  30      $qid = $question->getID();
  31      $view_uri = "/Q{$qid}";
  32  
  33      $xactions = array();
  34      $xactions[] = id(new PonderQuestionTransaction())
  35        ->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)
  36        ->attachComment(
  37          id(new PonderQuestionTransactionComment())
  38            ->setContent($request->getStr('comment')));
  39  
  40      $editor = id(new PonderQuestionEditor())
  41        ->setActor($viewer)
  42        ->setContinueOnNoEffect($request->isContinueRequest())
  43        ->setContentSourceFromRequest($request)
  44        ->setIsPreview($is_preview);
  45  
  46      try {
  47        $xactions = $editor->applyTransactions($question, $xactions);
  48      } catch (PhabricatorApplicationTransactionNoEffectException $ex) {
  49        return id(new PhabricatorApplicationTransactionNoEffectResponse())
  50          ->setCancelURI($view_uri)
  51          ->setException($ex);
  52      }
  53  
  54  //    if ($draft) {
  55  //      $draft->replaceOrDelete();
  56  //    }
  57  
  58      if ($request->isAjax() && $is_preview) {
  59        return id(new PhabricatorApplicationTransactionResponse())
  60          ->setViewer($viewer)
  61          ->setTransactions($xactions)
  62          ->setIsPreview($is_preview);
  63      } else {
  64        return id(new AphrontRedirectResponse())
  65          ->setURI($view_uri);
  66      }
  67    }
  68  
  69  }


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1