Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / slowvote / controller / PhabricatorSlowvoteCommentController.php
blob3d48c31866c5b282d9beb8a971891fb2f74dbe8e
1 <?php
3 final class PhabricatorSlowvoteCommentController
4 extends PhabricatorSlowvoteController {
6 public function handleRequest(AphrontRequest $request) {
7 $viewer = $request->getViewer();
8 $id = $request->getURIData('id');
10 if (!$request->isFormPost()) {
11 return new Aphront400Response();
14 $poll = id(new PhabricatorSlowvoteQuery())
15 ->setViewer($viewer)
16 ->withIDs(array($id))
17 ->executeOne();
18 if (!$poll) {
19 return new Aphront404Response();
22 $is_preview = $request->isPreviewRequest();
23 $draft = PhabricatorDraft::buildFromRequest($request);
25 $view_uri = '/V'.$poll->getID();
27 $xactions = array();
28 $xactions[] = id(new PhabricatorSlowvoteTransaction())
29 ->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)
30 ->attachComment(
31 id(new PhabricatorSlowvoteTransactionComment())
32 ->setContent($request->getStr('comment')));
34 $editor = id(new PhabricatorSlowvoteEditor())
35 ->setActor($viewer)
36 ->setContinueOnNoEffect($request->isContinueRequest())
37 ->setContentSourceFromRequest($request)
38 ->setIsPreview($is_preview);
40 try {
41 $xactions = $editor->applyTransactions($poll, $xactions);
42 } catch (PhabricatorApplicationTransactionNoEffectException $ex) {
43 return id(new PhabricatorApplicationTransactionNoEffectResponse())
44 ->setCancelURI($view_uri)
45 ->setException($ex);
48 if ($draft) {
49 $draft->replaceOrDelete();
52 if ($request->isAjax() && $is_preview) {
53 return id(new PhabricatorApplicationTransactionResponse())
54 ->setObject($poll)
55 ->setViewer($viewer)
56 ->setTransactions($xactions)
57 ->setIsPreview($is_preview);
58 } else {
59 return id(new AphrontRedirectResponse())
60 ->setURI($view_uri);