Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / applications / macro / controller / PhabricatorMacroDisableController.php
blob6c74e444427feaf8fe1144eae9263e7d09336609
1 <?php
3 final class PhabricatorMacroDisableController
4 extends PhabricatorMacroController {
6 public function handleRequest(AphrontRequest $request) {
7 $viewer = $request->getViewer();
8 $id = $request->getURIData('id');
10 $this->requireApplicationCapability(
11 PhabricatorMacroManageCapability::CAPABILITY);
13 $macro = id(new PhabricatorMacroQuery())
14 ->setViewer($viewer)
15 ->withIDs(array($id))
16 ->executeOne();
17 if (!$macro) {
18 return new Aphront404Response();
21 $view_uri = $this->getApplicationURI('/view/'.$id.'/');
23 if ($request->isDialogFormPost() || $macro->getIsDisabled()) {
24 $xaction = id(new PhabricatorMacroTransaction())
25 ->setTransactionType(
26 PhabricatorMacroDisabledTransaction::TRANSACTIONTYPE)
27 ->setNewValue($macro->getIsDisabled() ? 0 : 1);
29 $editor = id(new PhabricatorMacroEditor())
30 ->setActor($viewer)
31 ->setContentSourceFromRequest($request);
33 $xactions = $editor->applyTransactions($macro, array($xaction));
35 return id(new AphrontRedirectResponse())->setURI($view_uri);
38 $dialog = new AphrontDialogView();
39 $dialog
40 ->setUser($request->getUser())
41 ->setTitle(pht('Really disable macro?'))
42 ->appendChild(
43 phutil_tag(
44 'p',
45 array(),
46 pht(
47 'Really disable the much-beloved image macro %s? '.
48 'It will be sorely missed.',
49 $macro->getName())))
50 ->setSubmitURI($this->getApplicationURI('/disable/'.$id.'/'))
51 ->addSubmitButton(pht('Disable'))
52 ->addCancelButton($view_uri);
54 return id(new AphrontDialogResponse())->setDialog($dialog);