1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-14 19:02:41 +01:00
phorge-phorge/src/applications/pholio/controller/PholioMockCommentController.php

59 lines
1.4 KiB
PHP
Raw Normal View History

<?php
/**
* @group pholio
*/
final class PholioMockCommentController extends PholioController {
private $id;
public function willProcessRequest(array $data) {
$this->id = $data['id'];
}
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
$mock = id(new PholioMockQuery())
->setViewer($user)
->withIDs(array($this->id))
->executeOne();
if (!$mock) {
return new Aphront404Response();
}
$mock_uri = '/M'.$mock->getID();
$comment = $request->getStr('comment');
if (!strlen($comment)) {
$dialog = id(new AphrontDialogView())
->setUser($user)
->setTitle(pht('Empty Comment'))
->appendChild('You did not provide a comment!')
->addCancelButton($mock_uri);
return id(new AphrontDialogResponse())->setDialog($dialog);
}
$content_source = PhabricatorContentSource::newForSource(
PhabricatorContentSource::SOURCE_WEB,
array(
'ip' => $request->getRemoteAddr(),
));
$xaction = id(new PholioTransaction())
->setTransactionType(PholioTransactionType::TYPE_NONE)
->setComment($comment);
id(new PholioMockEditor())
->setActor($user)
->setContentSource($content_source)
->applyTransactions($mock, array($xaction));
return id(new AphrontRedirectResponse())->setURI($mock_uri);
}
}