@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
at upstream/main 61 lines 1.9 kB view raw
1<?php 2 3final class PhabricatorEditEngineConfigurationDefaultCreateController 4 extends PhabricatorEditEngineController { 5 6 public function handleRequest(AphrontRequest $request) { 7 $viewer = $this->getViewer(); 8 9 $config = $this->loadConfigForEdit(); 10 if (!$config) { 11 return id(new Aphront404Response()); 12 } 13 14 $engine_key = $config->getEngineKey(); 15 $key = $config->getIdentifier(); 16 $cancel_uri = "/transactions/editengine/{$engine_key}/view/{$key}/"; 17 18 $type = PhabricatorEditEngineDefaultCreateTransaction::TRANSACTIONTYPE; 19 20 if ($request->isFormPost()) { 21 $xactions = array(); 22 23 $xactions[] = id(new PhabricatorEditEngineConfigurationTransaction()) 24 ->setTransactionType($type) 25 ->setNewValue(!$config->getIsDefault()); 26 27 $editor = id(new PhabricatorEditEngineConfigurationEditor()) 28 ->setActor($viewer) 29 ->setContentSourceFromRequest($request) 30 ->setContinueOnMissingFields(true) 31 ->setContinueOnNoEffect(true); 32 33 $editor->applyTransactions($config, $xactions); 34 35 return id(new AphrontRedirectResponse()) 36 ->setURI($cancel_uri); 37 } 38 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'); 52 } 53 54 return $this->newDialog() 55 ->setTitle($title) 56 ->appendParagraph($body) 57 ->addSubmitButton($button) 58 ->addCancelbutton($cancel_uri); 59 } 60 61}