3 final class PhabricatorBadgesCommentController
4 extends PhabricatorBadgesController
{
6 public function handleRequest(AphrontRequest
$request) {
7 $viewer = $request->getViewer();
8 $id = $request->getURIData('id');
10 if (!$request->isFormPost()) {
11 return new Aphront400Response();
14 $badge = id(new PhabricatorBadgesQuery())
19 return new Aphront404Response();
22 $is_preview = $request->isPreviewRequest();
23 $draft = PhabricatorDraft
::buildFromRequest($request);
25 $view_uri = $this->getApplicationURI('view/'.$badge->getID());
28 $xactions[] = id(new PhabricatorBadgesTransaction())
29 ->setTransactionType(PhabricatorTransactions
::TYPE_COMMENT
)
31 id(new PhabricatorBadgesTransactionComment())
32 ->setContent($request->getStr('comment')));
34 $editor = id(new PhabricatorBadgesEditor())
36 ->setContinueOnNoEffect($request->isContinueRequest())
37 ->setContentSourceFromRequest($request)
38 ->setIsPreview($is_preview);
41 $xactions = $editor->applyTransactions($badge, $xactions);
42 } catch (PhabricatorApplicationTransactionNoEffectException
$ex) {
43 return id(new PhabricatorApplicationTransactionNoEffectResponse())
44 ->setCancelURI($view_uri)
49 $draft->replaceOrDelete();
52 if ($request->isAjax() && $is_preview) {
53 return id(new PhabricatorApplicationTransactionResponse())
56 ->setTransactions($xactions)
57 ->setIsPreview($is_preview);
59 return id(new AphrontRedirectResponse())