1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-25 08:12:40 +01:00
phorge-phorge/src/applications/ponder/controller/PonderAnswerPreviewController.php

39 lines
965 B
PHP
Raw Normal View History

<?php
final class PonderAnswerPreviewController
extends PonderController {
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
$question_id = $request->getInt('question_id');
$question = PonderQuestionQuery::loadSingle($user, $question_id);
if (!$question) {
return new Aphront404Response();
}
$author_phid = $user->getPHID();
$object_phids = array($author_phid);
$handles = $this->loadViewerHandles($object_phids);
$answer = new PonderAnswer();
$answer->setContent($request->getStr('content'));
$answer->setAuthorPHID($author_phid);
$view = new PonderPostBodyView();
$view
->setQuestion($question)
->setTarget($answer)
->setPreview(true)
->setUser($user)
->setHandles($handles)
->setAction(PonderLiterals::LITERAL_ANSWERED);
return id(new AphrontAjaxResponse())
->setContent($view->render());
}
}