Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / applications / pholio / controller / PholioMockArchiveController.php
blobfeca94610b697a86a2e188464343029e434e49fa
1 <?php
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())
11 ->setViewer($viewer)
12 ->withIDs(array($id))
13 ->requireCapabilities(
14 array(
15 PhabricatorPolicyCapability::CAN_VIEW,
16 PhabricatorPolicyCapability::CAN_EDIT,
18 ->executeOne();
19 if (!$mock) {
20 return new Aphront404Response();
23 $view_uri = '/M'.$mock->getID();
25 if ($request->isFormPost()) {
26 if ($mock->isClosed()) {
27 $new_status = PholioMock::STATUS_OPEN;
28 } else {
29 $new_status = PholioMock::STATUS_CLOSED;
32 $xactions = array();
34 $xactions[] = id(new PholioTransaction())
35 ->setTransactionType(PholioMockStatusTransaction::TRANSACTIONTYPE)
36 ->setNewValue($new_status);
38 id(new PholioMockEditor())
39 ->setActor($viewer)
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');
52 } else {
53 $title = pht('Close Pholio Mock');
54 $body = pht('This mock will be closed.');
55 $button = pht('Close Mock');
58 return $this->newDialog()
59 ->setTitle($title)
60 ->appendChild($body)
61 ->addCancelButton($view_uri)
62 ->addSubmitButton($button);