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())
14 ->withClasses(array($application_name))
15 ->requireCapabilities(
17 PhabricatorPolicyCapability
::CAN_VIEW
,
18 PhabricatorPolicyCapability
::CAN_EDIT
,
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())
33 ->addCancelButton($view_uri);
35 if ($application->isPrototype() && !$prototypes_enabled) {
37 ->setTitle(pht('Prototypes Not Enabled'))
40 'To manage prototypes, enable them by setting %s in your '.
42 phutil_tag('tt', array(), 'phabricator.show-prototypes')));
43 return id(new AphrontDialogResponse())->setDialog($dialog);
46 if ($request->isDialogFormPost()) {
48 $template = $application->getApplicationTransactionTemplate();
49 $xactions[] = id(clone $template)
51 PhabricatorApplicationUninstallTransaction
::TRANSACTIONTYPE
)
52 ->setNewValue($action);
54 $editor = id(new PhabricatorApplicationEditor())
56 ->setContentSourceFromRequest($request)
57 ->setContinueOnNoEffect(true)
58 ->setContinueOnMissingFields(true);
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()) {
76 ->setTitle(pht('Confirmation'))
79 'Install %s application?',
80 $application->getName()))
81 ->addSubmitButton(pht('Install'));
85 ->setTitle(pht('Information'))
86 ->appendChild(pht('You cannot install an installed application.'));
89 if ($application->canUninstall()) {
90 $dialog->setTitle(pht('Really Uninstall Application?'));
92 if ($application instanceof PhabricatorHomeApplication
) {
96 'Are you absolutely certain you want to uninstall the Home '.
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'));
108 'Really uninstall the %s application?',
109 $application->getName()))
110 ->addSubmitButton(pht('Uninstall'));
114 ->setTitle(pht('Information'))
117 'This application is required and cannot be uninstalled.'));
120 return id(new AphrontDialogResponse())->setDialog($dialog);