mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-19 19:21:10 +01:00
e6967ed2ec
Summary: Ref T3578. Unroll these static methods for consistency. Test Plan: grep Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T3578 Differential Revision: https://secure.phabricator.com/D6602
62 lines
1.6 KiB
PHP
62 lines
1.6 KiB
PHP
<?php
|
|
|
|
final class PonderCommentSaveController extends PonderController {
|
|
|
|
public function processRequest() {
|
|
$request = $this->getRequest();
|
|
if (!$request->isFormPost()) {
|
|
return new Aphront400Response();
|
|
}
|
|
|
|
$user = $request->getUser();
|
|
$question_id = $request->getInt('question_id');
|
|
$question = id(new PonderQuestionQuery())
|
|
->setViewer($user)
|
|
->withIDs(array($question_id))
|
|
->executeOne();
|
|
if (!$question) {
|
|
return new Aphront404Response();
|
|
}
|
|
|
|
$question->attachRelated();
|
|
|
|
$target = $request->getStr('target');
|
|
$objects = id(new PhabricatorObjectHandleData(array($target)))
|
|
->setViewer($user)
|
|
->loadHandles();
|
|
if (!$objects) {
|
|
return new Aphront404Response();
|
|
}
|
|
|
|
$content = $request->getStr('content');
|
|
|
|
if (!strlen(trim($content))) {
|
|
$dialog = new AphrontDialogView();
|
|
$dialog->setUser($request->getUser());
|
|
$dialog->setTitle(pht('Empty Comment'));
|
|
$dialog->appendChild(phutil_tag('p', array(), pht(
|
|
'Your comment must not be empty.')));
|
|
$dialog->addCancelButton('/Q'.$question_id);
|
|
|
|
return id(new AphrontDialogResponse())->setDialog($dialog);
|
|
}
|
|
|
|
$res = new PonderComment();
|
|
$res
|
|
->setContent($content)
|
|
->setAuthorPHID($user->getPHID())
|
|
->setTargetPHID($target);
|
|
|
|
id(new PonderCommentEditor())
|
|
->setQuestion($question)
|
|
->setComment($res)
|
|
->setTargetPHID($target)
|
|
->setActor($user)
|
|
->save();
|
|
|
|
return id(new AphrontRedirectResponse())
|
|
->setURI(
|
|
id(new PhutilURI('/Q'. $question->getID())));
|
|
}
|
|
|
|
}
|