3 final class DiffusionRepositoryURIDisableController
4 extends DiffusionController
{
6 public function handleRequest(AphrontRequest
$request) {
7 $response = $this->loadDiffusionContextForEdit();
12 $viewer = $this->getViewer();
13 $drequest = $this->getDiffusionRequest();
14 $repository = $drequest->getRepository();
16 $id = $request->getURIData('id');
17 $uri = id(new PhabricatorRepositoryURIQuery())
20 ->withRepositories(array($repository))
21 ->requireCapabilities(
23 PhabricatorPolicyCapability
::CAN_VIEW
,
24 PhabricatorPolicyCapability
::CAN_EDIT
,
28 return new Aphront404Response();
31 $is_disabled = $uri->getIsDisabled();
32 $view_uri = $uri->getViewURI();
34 if ($uri->isBuiltin()) {
35 return $this->newDialog()
36 ->setTitle(pht('Builtin URI'))
39 'You can not manually disable builtin URIs. To hide a builtin '.
40 'URI, configure its "Display" behavior instead.'))
41 ->addCancelButton($view_uri);
44 if ($request->isFormPost()) {
47 $xactions[] = id(new PhabricatorRepositoryURITransaction())
48 ->setTransactionType(PhabricatorRepositoryURITransaction
::TYPE_DISABLE
)
49 ->setNewValue(!$is_disabled);
51 $editor = id(new DiffusionURIEditor())
53 ->setContinueOnNoEffect(true)
54 ->setContinueOnMissingFields(true)
55 ->setContentSourceFromRequest($request)
56 ->applyTransactions($uri, $xactions);
58 return id(new AphrontRedirectResponse())->setURI($view_uri);
62 $title = pht('Enable URI');
64 'Enable this URI? Any configured behaviors will begin working '.
66 $button = pht('Enable URI');
68 $title = pht('Disable URI');
70 'Disable this URI? It will no longer be observed, fetched, mirrored, '.
71 'served or shown to users.');
72 $button = pht('Disable URI');
75 return $this->newDialog()
77 ->appendParagraph($body)
78 ->addCancelButton($view_uri)
79 ->addSubmitButton($button);