mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-25 08:12:40 +01:00
64 lines
1.8 KiB
PHP
64 lines
1.8 KiB
PHP
|
<?php
|
||
|
|
||
|
final class ReleephRequestCommentController
|
||
|
extends ReleephController {
|
||
|
|
||
|
public function processRequest() {
|
||
|
$request = $this->getRequest();
|
||
|
$user = $request->getUser();
|
||
|
|
||
|
$rq = $this->getReleephRequest();
|
||
|
|
||
|
if (!$request->isFormPost()) {
|
||
|
return new Aphront400Response();
|
||
|
}
|
||
|
|
||
|
$is_preview = $request->isPreviewRequest();
|
||
|
$draft = PhabricatorDraft::buildFromRequest($request);
|
||
|
|
||
|
$view_uri = $this->getApplicationURI('/RQ'.$rq->getID());
|
||
|
|
||
|
$xactions = array();
|
||
|
$xactions[] = id(new ReleephRequestTransaction())
|
||
|
->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)
|
||
|
->attachComment(
|
||
|
id(new ReleephRequestTransactionComment())
|
||
|
->setContent($request->getStr('comment')));
|
||
|
|
||
|
$editor = id(new ReleephRequestTransactionalEditor())
|
||
|
->setActor($user)
|
||
|
->setContinueOnNoEffect($request->isContinueRequest())
|
||
|
->setContentSource(
|
||
|
PhabricatorContentSource::newForSource(
|
||
|
PhabricatorContentSource::SOURCE_WEB,
|
||
|
array(
|
||
|
'ip' => $request->getRemoteAddr(),
|
||
|
)))
|
||
|
->setIsPreview($is_preview);
|
||
|
|
||
|
try {
|
||
|
$xactions = $editor->applyTransactions($rq, $xactions);
|
||
|
} catch (PhabricatorApplicationTransactionNoEffectException $ex) {
|
||
|
return id(new PhabricatorApplicationTransactionNoEffectResponse())
|
||
|
->setCancelURI($view_uri)
|
||
|
->setException($ex);
|
||
|
}
|
||
|
|
||
|
if ($draft) {
|
||
|
$draft->replaceOrDelete();
|
||
|
}
|
||
|
|
||
|
if ($request->isAjax()) {
|
||
|
return id(new PhabricatorApplicationTransactionResponse())
|
||
|
->setViewer($user)
|
||
|
->setTransactions($xactions)
|
||
|
->setIsPreview($is_preview)
|
||
|
->setAnchorOffset($request->getStr('anchor'));
|
||
|
} else {
|
||
|
return id(new AphrontRedirectResponse())
|
||
|
->setURI($view_uri);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|