1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-02-18 01:38:39 +01:00
phorge-phorge/src/applications/releeph/controller/request/ReleephRequestCommentController.php
epriestley 904a24c1df Provide an application-wide controller for Releeph
Summary: Fixes T3548. Concrete Releeph controllers currently extend either from ReleephController or PhabricatorController directly. Instead, make them all extend ReleephController. Introduce ReleephProjectController for controllers which depend on project context. Project context code which lived in ReleephController moves to ReleephProjectController.

Test Plan: Viewed list, project, releases, requests.

Reviewers: btrahan, edward

Reviewed By: edward

CC: aran

Maniphest Tasks: T3548

Differential Revision: https://secure.phabricator.com/D6472
2013-07-21 08:42:10 -07:00

58 lines
1.6 KiB
PHP

<?php
final class ReleephRequestCommentController
extends ReleephProjectController {
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())
->setContentSourceFromRequest($request)
->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);
}
}
}