Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / applications / paste / controller / PhabricatorPasteArchiveController.php
blob143584e42685a7de577a5a1e8ba1fdbf7bf8f59a
1 <?php
3 final class PhabricatorPasteArchiveController
4 extends PhabricatorPasteController {
6 public function handleRequest(AphrontRequest $request) {
7 $viewer = $request->getViewer();
8 $id = $request->getURIData('id');
10 $paste = id(new PhabricatorPasteQuery())
11 ->setViewer($viewer)
12 ->withIDs(array($id))
13 ->requireCapabilities(
14 array(
15 PhabricatorPolicyCapability::CAN_VIEW,
16 PhabricatorPolicyCapability::CAN_EDIT,
18 ->executeOne();
19 if (!$paste) {
20 return new Aphront404Response();
23 $view_uri = $paste->getURI();
25 if ($request->isFormPost()) {
26 if ($paste->isArchived()) {
27 $new_status = PhabricatorPaste::STATUS_ACTIVE;
28 } else {
29 $new_status = PhabricatorPaste::STATUS_ARCHIVED;
32 $xactions = array();
34 $xactions[] = id(new PhabricatorPasteTransaction())
35 ->setTransactionType(PhabricatorPasteStatusTransaction::TRANSACTIONTYPE)
36 ->setNewValue($new_status);
38 id(new PhabricatorPasteEditor())
39 ->setActor($viewer)
40 ->setContentSourceFromRequest($request)
41 ->setContinueOnNoEffect(true)
42 ->setContinueOnMissingFields(true)
43 ->applyTransactions($paste, $xactions);
45 return id(new AphrontRedirectResponse())->setURI($view_uri);
48 if ($paste->isArchived()) {
49 $title = pht('Activate Paste');
50 $body = pht('This paste will become consumable again.');
51 $button = pht('Activate Paste');
52 } else {
53 $title = pht('Archive Paste');
54 $body = pht('This paste will be marked as expired.');
55 $button = pht('Archive Paste');
58 return $this->newDialog()
59 ->setTitle($title)
60 ->appendChild($body)
61 ->addCancelButton($view_uri)
62 ->addSubmitButton($button);