[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/macro/controller/ -> PhabricatorMacroCommentController.php (source)

   1  <?php
   2  
   3  final class PhabricatorMacroCommentController
   4    extends PhabricatorMacroController {
   5  
   6    private $id;
   7  
   8    public function willProcessRequest(array $data) {
   9      $this->id = idx($data, 'id');
  10    }
  11  
  12    public function processRequest() {
  13      $request = $this->getRequest();
  14      $user = $request->getUser();
  15  
  16      if (!$request->isFormPost()) {
  17        return new Aphront400Response();
  18      }
  19  
  20      $macro = id(new PhabricatorMacroQuery())
  21        ->setViewer($user)
  22        ->withIDs(array($this->id))
  23        ->executeOne();
  24      if (!$macro) {
  25        return new Aphront404Response();
  26      }
  27  
  28      $is_preview = $request->isPreviewRequest();
  29      $draft = PhabricatorDraft::buildFromRequest($request);
  30  
  31      $view_uri = $this->getApplicationURI('/view/'.$macro->getID().'/');
  32  
  33      $xactions = array();
  34      $xactions[] = id(new PhabricatorMacroTransaction())
  35        ->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)
  36        ->attachComment(
  37          id(new PhabricatorMacroTransactionComment())
  38            ->setContent($request->getStr('comment')));
  39  
  40      $editor = id(new PhabricatorMacroEditor())
  41        ->setActor($user)
  42        ->setContinueOnNoEffect($request->isContinueRequest())
  43        ->setContentSourceFromRequest($request)
  44        ->setIsPreview($is_preview);
  45  
  46      try {
  47        $xactions = $editor->applyTransactions($macro, $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($user)
  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