[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

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

   1  <?php
   2  
   3  final class PonderAnswerCommentController 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      $answer = id(new PonderAnswerQuery())
  20        ->setViewer($viewer)
  21        ->withIDs(array($this->id))
  22        ->executeOne();
  23      if (!$answer) {
  24        return new Aphront404Response();
  25      }
  26  
  27      $is_preview = $request->isPreviewRequest();
  28  //    $draft = PhabricatorDraft::buildFromRequest($request);
  29  
  30      $qid = $answer->getQuestion()->getID();
  31      $aid = $answer->getID();
  32      $view_uri = "Q{$qid}#A{$aid}";
  33  
  34      $xactions = array();
  35      $xactions[] = id(new PonderAnswerTransaction())
  36        ->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)
  37        ->attachComment(
  38          id(new PonderAnswerTransactionComment())
  39            ->setContent($request->getStr('comment')));
  40  
  41      $editor = id(new PonderAnswerEditor())
  42        ->setActor($viewer)
  43        ->setContinueOnNoEffect($request->isContinueRequest())
  44        ->setContentSourceFromRequest($request)
  45        ->setIsPreview($is_preview);
  46  
  47      try {
  48        $xactions = $editor->applyTransactions($answer, $xactions);
  49      } catch (PhabricatorApplicationTransactionNoEffectException $ex) {
  50        return id(new PhabricatorApplicationTransactionNoEffectResponse())
  51          ->setCancelURI($view_uri)
  52          ->setException($ex);
  53      }
  54  
  55  //    if ($draft) {
  56  //      $draft->replaceOrDelete();
  57  //    }
  58  
  59      if ($request->isAjax() && $is_preview) {
  60        return id(new PhabricatorApplicationTransactionResponse())
  61          ->setViewer($viewer)
  62          ->setTransactions($xactions)
  63          ->setIsPreview($is_preview);
  64      } else {
  65        return id(new AphrontRedirectResponse())
  66          ->setURI($view_uri);
  67      }
  68    }
  69  
  70  }


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