[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/files/controller/ -> PhabricatorFileCommentController.php (source)

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


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