Remove product literal strings in "pht()", part 6
[phabricator.git] / src / applications / meta / controller / PhabricatorApplicationUninstallController.php
blobe89976c42c1d9e41ee2bf28f522a0f4639269414
1 <?php
3 final class PhabricatorApplicationUninstallController
4 extends PhabricatorApplicationsController {
6 public function handleRequest(AphrontRequest $request) {
7 $viewer = $request->getViewer();
8 $user = $request->getUser();
9 $action = $request->getURIData('action');
10 $application_name = $request->getURIData('application');
12 $application = id(new PhabricatorApplicationQuery())
13 ->setViewer($viewer)
14 ->withClasses(array($application_name))
15 ->requireCapabilities(
16 array(
17 PhabricatorPolicyCapability::CAN_VIEW,
18 PhabricatorPolicyCapability::CAN_EDIT,
20 ->executeOne();
22 if (!$application) {
23 return new Aphront404Response();
26 $view_uri = $this->getApplicationURI('view/'.$application_name);
28 $prototypes_enabled = PhabricatorEnv::getEnvConfig(
29 'phabricator.show-prototypes');
31 $dialog = id(new AphrontDialogView())
32 ->setUser($viewer)
33 ->addCancelButton($view_uri);
35 if ($application->isPrototype() && !$prototypes_enabled) {
36 $dialog
37 ->setTitle(pht('Prototypes Not Enabled'))
38 ->appendChild(
39 pht(
40 'To manage prototypes, enable them by setting %s in your '.
41 'configuration.',
42 phutil_tag('tt', array(), 'phabricator.show-prototypes')));
43 return id(new AphrontDialogResponse())->setDialog($dialog);
46 if ($request->isDialogFormPost()) {
47 $xactions = array();
48 $template = $application->getApplicationTransactionTemplate();
49 $xactions[] = id(clone $template)
50 ->setTransactionType(
51 PhabricatorApplicationUninstallTransaction::TRANSACTIONTYPE)
52 ->setNewValue($action);
54 $editor = id(new PhabricatorApplicationEditor())
55 ->setActor($user)
56 ->setContentSourceFromRequest($request)
57 ->setContinueOnNoEffect(true)
58 ->setContinueOnMissingFields(true);
60 try {
61 $editor->applyTransactions($application, $xactions);
62 return id(new AphrontRedirectResponse())->setURI($view_uri);
63 } catch (PhabricatorApplicationTransactionValidationException $ex) {
64 $validation_exception = $ex;
67 return $this->newDialog()
68 ->setTitle(pht('Validation Failed'))
69 ->setValidationException($validation_exception)
70 ->addCancelButton($view_uri);
73 if ($action == 'install') {
74 if ($application->canUninstall()) {
75 $dialog
76 ->setTitle(pht('Confirmation'))
77 ->appendChild(
78 pht(
79 'Install %s application?',
80 $application->getName()))
81 ->addSubmitButton(pht('Install'));
83 } else {
84 $dialog
85 ->setTitle(pht('Information'))
86 ->appendChild(pht('You cannot install an installed application.'));
88 } else {
89 if ($application->canUninstall()) {
90 $dialog->setTitle(pht('Really Uninstall Application?'));
92 if ($application instanceof PhabricatorHomeApplication) {
93 $dialog
94 ->appendParagraph(
95 pht(
96 'Are you absolutely certain you want to uninstall the Home '.
97 'application?'))
98 ->appendParagraph(
99 pht(
100 'This is very unusual and will leave you without any '.
101 'content on the home page. You should only do this if you '.
102 'are certain you know what you are doing.'))
103 ->addSubmitButton(pht('Completely Break Everything'));
104 } else {
105 $dialog
106 ->appendParagraph(
107 pht(
108 'Really uninstall the %s application?',
109 $application->getName()))
110 ->addSubmitButton(pht('Uninstall'));
112 } else {
113 $dialog
114 ->setTitle(pht('Information'))
115 ->appendChild(
116 pht(
117 'This application is required and cannot be uninstalled.'));
120 return id(new AphrontDialogResponse())->setDialog($dialog);