3 final class PholioMockArchiveController
4 extends PholioController
{
6 public function handleRequest(AphrontRequest
$request) {
7 $viewer = $request->getViewer();
8 $id = $request->getURIData('id');
10 $mock = id(new PholioMockQuery())
13 ->requireCapabilities(
15 PhabricatorPolicyCapability
::CAN_VIEW
,
16 PhabricatorPolicyCapability
::CAN_EDIT
,
20 return new Aphront404Response();
23 $view_uri = '/M'.$mock->getID();
25 if ($request->isFormPost()) {
26 if ($mock->isClosed()) {
27 $new_status = PholioMock
::STATUS_OPEN
;
29 $new_status = PholioMock
::STATUS_CLOSED
;
34 $xactions[] = id(new PholioTransaction())
35 ->setTransactionType(PholioMockStatusTransaction
::TRANSACTIONTYPE
)
36 ->setNewValue($new_status);
38 id(new PholioMockEditor())
40 ->setContentSourceFromRequest($request)
41 ->setContinueOnNoEffect(true)
42 ->setContinueOnMissingFields(true)
43 ->applyTransactions($mock, $xactions);
45 return id(new AphrontRedirectResponse())->setURI($view_uri);
48 if ($mock->isClosed()) {
49 $title = pht('Open Pholio Mock');
50 $body = pht('This mock will become open again.');
51 $button = pht('Open Mock');
53 $title = pht('Close Pholio Mock');
54 $body = pht('This mock will be closed.');
55 $button = pht('Close Mock');
58 return $this->newDialog()
61 ->addCancelButton($view_uri)
62 ->addSubmitButton($button);