2013-04-08 17:34:21 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class ReleephRequestCommentController
|
2014-04-14 21:06:56 +02:00
|
|
|
extends ReleephRequestController {
|
|
|
|
|
|
|
|
private $requestID;
|
|
|
|
|
|
|
|
public function willProcessRequest(array $data) {
|
|
|
|
$this->requestID = $data['requestID'];
|
|
|
|
}
|
2013-04-08 17:34:21 +02:00
|
|
|
|
|
|
|
public function processRequest() {
|
|
|
|
$request = $this->getRequest();
|
2014-04-14 21:06:56 +02:00
|
|
|
$viewer = $request->getUser();
|
2013-04-08 17:34:21 +02:00
|
|
|
|
|
|
|
if (!$request->isFormPost()) {
|
|
|
|
return new Aphront400Response();
|
|
|
|
}
|
|
|
|
|
2014-04-14 21:06:56 +02:00
|
|
|
$pull = id(new ReleephRequestQuery())
|
|
|
|
->setViewer($viewer)
|
|
|
|
->withIDs(array($this->requestID))
|
|
|
|
->executeOne();
|
|
|
|
if (!$pull) {
|
|
|
|
return new Aphront404Response();
|
|
|
|
}
|
|
|
|
|
2013-04-08 17:34:21 +02:00
|
|
|
$is_preview = $request->isPreviewRequest();
|
|
|
|
$draft = PhabricatorDraft::buildFromRequest($request);
|
|
|
|
|
2014-04-14 21:06:56 +02:00
|
|
|
$view_uri = $this->getApplicationURI('/'.$pull->getMonogram());
|
2013-04-08 17:34:21 +02:00
|
|
|
|
|
|
|
$xactions = array();
|
|
|
|
$xactions[] = id(new ReleephRequestTransaction())
|
|
|
|
->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)
|
|
|
|
->attachComment(
|
|
|
|
id(new ReleephRequestTransactionComment())
|
|
|
|
->setContent($request->getStr('comment')));
|
|
|
|
|
|
|
|
$editor = id(new ReleephRequestTransactionalEditor())
|
2014-04-14 21:06:56 +02:00
|
|
|
->setActor($viewer)
|
2013-04-08 17:34:21 +02:00
|
|
|
->setContinueOnNoEffect($request->isContinueRequest())
|
2013-05-24 19:48:34 +02:00
|
|
|
->setContentSourceFromRequest($request)
|
2013-04-08 17:34:21 +02:00
|
|
|
->setIsPreview($is_preview);
|
|
|
|
|
|
|
|
try {
|
2014-04-14 21:06:56 +02:00
|
|
|
$xactions = $editor->applyTransactions($pull, $xactions);
|
2013-04-08 17:34:21 +02:00
|
|
|
} catch (PhabricatorApplicationTransactionNoEffectException $ex) {
|
|
|
|
return id(new PhabricatorApplicationTransactionNoEffectResponse())
|
|
|
|
->setCancelURI($view_uri)
|
|
|
|
->setException($ex);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($draft) {
|
|
|
|
$draft->replaceOrDelete();
|
|
|
|
}
|
|
|
|
|
2014-06-21 21:50:40 +02:00
|
|
|
if ($request->isAjax() && $is_preview) {
|
2013-04-08 17:34:21 +02:00
|
|
|
return id(new PhabricatorApplicationTransactionResponse())
|
2014-04-14 21:06:56 +02:00
|
|
|
->setViewer($viewer)
|
2013-04-08 17:34:21 +02:00
|
|
|
->setTransactions($xactions)
|
2014-09-16 21:12:35 +02:00
|
|
|
->setIsPreview($is_preview);
|
2013-04-08 17:34:21 +02:00
|
|
|
} else {
|
|
|
|
return id(new AphrontRedirectResponse())
|
|
|
|
->setURI($view_uri);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|