Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / transactions / controller / PhabricatorEditEngineConfigurationDefaultCreateController.php
blob039bfb0f44dda3cf4717004b0ddea1bc07a7fc4e
1 <?php
3 final class PhabricatorEditEngineConfigurationDefaultCreateController
4 extends PhabricatorEditEngineController {
6 public function handleRequest(AphrontRequest $request) {
7 $viewer = $this->getViewer();
9 $config = $this->loadConfigForEdit();
10 if (!$config) {
11 return id(new Aphront404Response());
14 $engine_key = $config->getEngineKey();
15 $key = $config->getIdentifier();
16 $cancel_uri = "/transactions/editengine/{$engine_key}/view/{$key}/";
18 $type = PhabricatorEditEngineDefaultCreateTransaction::TRANSACTIONTYPE;
20 if ($request->isFormPost()) {
21 $xactions = array();
23 $xactions[] = id(new PhabricatorEditEngineConfigurationTransaction())
24 ->setTransactionType($type)
25 ->setNewValue(!$config->getIsDefault());
27 $editor = id(new PhabricatorEditEngineConfigurationEditor())
28 ->setActor($viewer)
29 ->setContentSourceFromRequest($request)
30 ->setContinueOnMissingFields(true)
31 ->setContinueOnNoEffect(true);
33 $editor->applyTransactions($config, $xactions);
35 return id(new AphrontRedirectResponse())
36 ->setURI($cancel_uri);
39 if ($config->getIsDefault()) {
40 $title = pht('Unmark as Create Form');
41 $body = pht(
42 'Unmark this form as a create form? It will still function properly, '.
43 'but no longer be reachable directly from the application "Create" '.
44 'menu.');
45 $button = pht('Unmark Form');
46 } else {
47 $title = pht('Mark as Create Form');
48 $body = pht(
49 'Mark this form as a create form? It will appear in the application '.
50 '"Create" menus by default.');
51 $button = pht('Mark Form');
54 return $this->newDialog()
55 ->setTitle($title)
56 ->appendParagraph($body)
57 ->addSubmitButton($button)
58 ->addCancelbutton($cancel_uri);