@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
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Convert Macro to handleRequest

Summary: Converts Macro app

Test Plan: Make Macro, Make meme

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: epriestley, Korvin

Maniphest Tasks: T8628

Differential Revision: https://secure.phabricator.com/D13724

+53 -89
+4 -10
src/applications/macro/controller/PhabricatorMacroAudioController.php
··· 2 2 3 3 final class PhabricatorMacroAudioController extends PhabricatorMacroController { 4 4 5 - private $id; 6 - 7 - public function willProcessRequest(array $data) { 8 - $this->id = idx($data, 'id'); 9 - } 5 + public function handleRequest(AphrontRequest $request) { 6 + $viewer = $request->getViewer(); 7 + $id = $request->getURIData('id'); 10 8 11 - public function processRequest() { 12 9 $this->requireApplicationCapability( 13 10 PhabricatorMacroManageCapability::CAPABILITY); 14 11 15 - $request = $this->getRequest(); 16 - $viewer = $request->getUser(); 17 - 18 12 $macro = id(new PhabricatorMacroQuery()) 19 13 ->setViewer($viewer) 20 14 ->requireCapabilities( 21 15 array( 22 16 PhabricatorPolicyCapability::CAN_VIEW, 23 17 )) 24 - ->withIDs(array($this->id)) 18 + ->withIDs(array($id)) 25 19 ->executeOne(); 26 20 27 21 if (!$macro) {
+7 -13
src/applications/macro/controller/PhabricatorMacroCommentController.php
··· 3 3 final class PhabricatorMacroCommentController 4 4 extends PhabricatorMacroController { 5 5 6 - private $id; 7 - 8 - public function willProcessRequest(array $data) { 9 - $this->id = idx($data, 'id'); 10 - } 11 - 12 - public function processRequest() { 13 - $request = $this->getRequest(); 14 - $user = $request->getUser(); 6 + public function handleRequest(AphrontRequest $request) { 7 + $viewer = $request->getViewer(); 8 + $id = $request->getURIData('id'); 15 9 16 10 if (!$request->isFormPost()) { 17 11 return new Aphront400Response(); 18 12 } 19 13 20 14 $macro = id(new PhabricatorMacroQuery()) 21 - ->setViewer($user) 22 - ->withIDs(array($this->id)) 15 + ->setViewer($viewer) 16 + ->withIDs(array($id)) 23 17 ->executeOne(); 24 18 if (!$macro) { 25 19 return new Aphront404Response(); ··· 38 32 ->setContent($request->getStr('comment'))); 39 33 40 34 $editor = id(new PhabricatorMacroEditor()) 41 - ->setActor($user) 35 + ->setActor($viewer) 42 36 ->setContinueOnNoEffect($request->isContinueRequest()) 43 37 ->setContentSourceFromRequest($request) 44 38 ->setIsPreview($is_preview); ··· 57 51 58 52 if ($request->isAjax() && $is_preview) { 59 53 return id(new PhabricatorApplicationTransactionResponse()) 60 - ->setViewer($user) 54 + ->setViewer($viewer) 61 55 ->setTransactions($xactions) 62 56 ->setIsPreview($is_preview); 63 57 } else {
+8 -14
src/applications/macro/controller/PhabricatorMacroDisableController.php
··· 3 3 final class PhabricatorMacroDisableController 4 4 extends PhabricatorMacroController { 5 5 6 - private $id; 6 + public function handleRequest(AphrontRequest $request) { 7 + $viewer = $request->getViewer(); 8 + $id = $request->getURIData('id'); 7 9 8 - public function willProcessRequest(array $data) { 9 - $this->id = $data['id']; 10 - } 11 - 12 - public function processRequest() { 13 10 $this->requireApplicationCapability( 14 11 PhabricatorMacroManageCapability::CAPABILITY); 15 12 16 - $request = $this->getRequest(); 17 - $user = $request->getUser(); 18 - 19 13 $macro = id(new PhabricatorMacroQuery()) 20 - ->setViewer($user) 21 - ->withIDs(array($this->id)) 14 + ->setViewer($viewer) 15 + ->withIDs(array($id)) 22 16 ->executeOne(); 23 17 if (!$macro) { 24 18 return new Aphront404Response(); 25 19 } 26 20 27 - $view_uri = $this->getApplicationURI('/view/'.$this->id.'/'); 21 + $view_uri = $this->getApplicationURI('/view/'.$id.'/'); 28 22 29 23 if ($request->isDialogFormPost() || $macro->getIsDisabled()) { 30 24 $xaction = id(new PhabricatorMacroTransaction()) ··· 32 26 ->setNewValue($macro->getIsDisabled() ? 0 : 1); 33 27 34 28 $editor = id(new PhabricatorMacroEditor()) 35 - ->setActor($user) 29 + ->setActor($viewer) 36 30 ->setContentSourceFromRequest($request); 37 31 38 32 $xactions = $editor->applyTransactions($macro, array($xaction)); ··· 52 46 'Really disable the much-beloved image macro %s? '. 53 47 'It will be sorely missed.', 54 48 $macro->getName()))) 55 - ->setSubmitURI($this->getApplicationURI('/disable/'.$this->id.'/')) 49 + ->setSubmitURI($this->getApplicationURI('/disable/'.$id.'/')) 56 50 ->addSubmitButton(pht('Disable')) 57 51 ->addCancelButton($view_uri); 58 52
+12 -18
src/applications/macro/controller/PhabricatorMacroEditController.php
··· 2 2 3 3 final class PhabricatorMacroEditController extends PhabricatorMacroController { 4 4 5 - private $id; 6 - 7 - public function willProcessRequest(array $data) { 8 - $this->id = idx($data, 'id'); 9 - } 5 + public function handleRequest(AphrontRequest $request) { 6 + $viewer = $request->getViewer(); 7 + $id = $request->getURIData('id'); 10 8 11 - public function processRequest() { 12 9 $this->requireApplicationCapability( 13 10 PhabricatorMacroManageCapability::CAPABILITY); 14 11 15 - $request = $this->getRequest(); 16 - $user = $request->getUser(); 17 - 18 - if ($this->id) { 12 + if ($id) { 19 13 $macro = id(new PhabricatorMacroQuery()) 20 - ->setViewer($user) 21 - ->withIDs(array($this->id)) 14 + ->setViewer($viewer) 15 + ->withIDs(array($id)) 22 16 ->needFiles(true) 23 17 ->executeOne(); 24 18 if (!$macro) { ··· 26 20 } 27 21 } else { 28 22 $macro = new PhabricatorFileImageMacro(); 29 - $macro->setAuthorPHID($user->getPHID()); 23 + $macro->setAuthorPHID($viewer->getPHID()); 30 24 } 31 25 32 26 $errors = array(); ··· 66 60 $_FILES['file'], 67 61 array( 68 62 'name' => $request->getStr('name'), 69 - 'authorPHID' => $user->getPHID(), 63 + 'authorPHID' => $viewer->getPHID(), 70 64 'isExplicitUpload' => true, 71 65 'canCDN' => true, 72 66 )); ··· 75 69 // Rate limit outbound fetches to make this mechanism less useful for 76 70 // scanning networks and ports. 77 71 PhabricatorSystemActionEngine::willTakeAction( 78 - array($user->getPHID()), 72 + array($viewer->getPHID()), 79 73 new PhabricatorFilesOutboundRequestAction(), 80 74 1); 81 75 ··· 101 95 $mime_type)); 102 96 } else { 103 97 $file 104 - ->setAuthorPHID($user->getPHID()) 98 + ->setAuthorPHID($viewer->getPHID()) 105 99 ->save(); 106 100 } 107 101 } catch (HTTPFutureHTTPResponseStatus $status) { ··· 114 108 } 115 109 } else if ($request->getStr('phid')) { 116 110 $file = id(new PhabricatorFileQuery()) 117 - ->setViewer($user) 111 + ->setViewer($viewer) 118 112 ->withPHIDs(array($request->getStr('phid'))) 119 113 ->executeOne(); 120 114 } ··· 152 146 } 153 147 154 148 $editor = id(new PhabricatorMacroEditor()) 155 - ->setActor($user) 149 + ->setActor($viewer) 156 150 ->setContinueOnNoEffect(true) 157 151 ->setContentSourceFromRequest($request); 158 152
+3 -7
src/applications/macro/controller/PhabricatorMacroListController.php
··· 2 2 3 3 final class PhabricatorMacroListController extends PhabricatorMacroController { 4 4 5 - private $key; 6 - 7 5 public function shouldAllowPublic() { 8 6 return true; 9 7 } 10 8 11 - public function willProcessRequest(array $data) { 12 - $this->key = idx($data, 'key'); 13 - } 9 + public function handleRequest(AphrontRequest $request) { 10 + $key = $request->getURIData('key'); 14 11 15 - public function processRequest() { 16 12 $controller = id(new PhabricatorApplicationSearchController()) 17 - ->setQueryKey($this->key) 13 + ->setQueryKey($key) 18 14 ->setSearchEngine(new PhabricatorMacroSearchEngine()) 19 15 ->setNavigation($this->buildSideNavView()); 20 16
+6 -7
src/applications/macro/controller/PhabricatorMacroMemeController.php
··· 7 7 return true; 8 8 } 9 9 10 - public function processRequest() { 11 - $request = $this->getRequest(); 10 + public function handleRequest(AphrontRequest $request) { 12 11 $macro_name = $request->getStr('macro'); 13 12 $upper_text = $request->getStr('uppertext'); 14 13 $lower_text = $request->getStr('lowertext'); 15 - $user = $request->getUser(); 14 + $viewer = $request->getViewer(); 16 15 17 - $uri = self::generateMacro($user, $macro_name, 16 + $uri = self::generateMacro($viewer, $macro_name, 18 17 $upper_text, $lower_text); 19 18 if ($uri === false) { 20 19 return new Aphront404Response(); ··· 24 23 ->setURI($uri); 25 24 } 26 25 27 - public static function generateMacro($user, $macro_name, $upper_text, 26 + public static function generateMacro($viewer, $macro_name, $upper_text, 28 27 $lower_text) { 29 28 $macro = id(new PhabricatorMacroQuery()) 30 - ->setViewer($user) 29 + ->setViewer($viewer) 31 30 ->withNames(array($macro_name)) 32 31 ->needFiles(true) 33 32 ->executeOne(); ··· 46 45 47 46 if ($xform) { 48 47 $memefile = id(new PhabricatorFileQuery()) 49 - ->setViewer($user) 48 + ->setViewer($viewer) 50 49 ->withPHIDs(array($xform->getTransformedPHID())) 51 50 ->executeOne(); 52 51 if ($memefile) {
+5 -6
src/applications/macro/controller/PhabricatorMacroMemeDialogController.php
··· 3 3 final class PhabricatorMacroMemeDialogController 4 4 extends PhabricatorMacroController { 5 5 6 - public function processRequest() { 7 - $request = $this->getRequest(); 8 - $user = $request->getUser(); 6 + public function handleRequest(AphrontRequest $request) { 7 + $viewer = $request->getViewer(); 9 8 10 9 $phid = head($request->getArr('macro')); 11 10 $above = $request->getStr('above'); ··· 19 18 $errors[] = pht('Macro name is required.'); 20 19 } else { 21 20 $macro = id(new PhabricatorMacroQuery()) 22 - ->setViewer($user) 21 + ->setViewer($viewer) 23 22 ->withPHIDs(array($phid)) 24 23 ->executeOne(); 25 24 if (!$macro) { ··· 45 44 } 46 45 47 46 $view = id(new AphrontFormView()) 48 - ->setUser($user) 47 + ->setUser($viewer) 49 48 ->appendControl( 50 49 id(new AphrontFormTokenizerControl()) 51 50 ->setLabel(pht('Macro')) ··· 65 64 ->setValue($below)); 66 65 67 66 $dialog = id(new AphrontDialogView()) 68 - ->setUser($user) 67 + ->setUser($viewer) 69 68 ->setTitle(pht('Create Meme')) 70 69 ->appendForm($view) 71 70 ->addCancelButton('/')
+8 -14
src/applications/macro/controller/PhabricatorMacroViewController.php
··· 3 3 final class PhabricatorMacroViewController 4 4 extends PhabricatorMacroController { 5 5 6 - private $id; 7 - 8 - public function willProcessRequest(array $data) { 9 - $this->id = $data['id']; 10 - } 11 - 12 6 public function shouldAllowPublic() { 13 7 return true; 14 8 } 15 9 16 - public function processRequest() { 17 - $request = $this->getRequest(); 18 - $user = $request->getUser(); 10 + public function handleRequest(AphrontRequest $request) { 11 + $viewer = $request->getViewer(); 12 + $id = $request->getURIData('id'); 19 13 20 14 $macro = id(new PhabricatorMacroQuery()) 21 - ->setViewer($user) 22 - ->withIDs(array($this->id)) 15 + ->setViewer($viewer) 16 + ->withIDs(array($id)) 23 17 ->needFiles(true) 24 18 ->executeOne(); 25 19 if (!$macro) { ··· 55 49 new PhabricatorMacroTransactionQuery()); 56 50 57 51 $header = id(new PHUIHeaderView()) 58 - ->setUser($user) 52 + ->setUser($viewer) 59 53 ->setPolicyObject($macro) 60 54 ->setHeader($title_long); 61 55 ··· 71 65 ? pht('Add Comment') 72 66 : pht('Grovel in Awe'); 73 67 74 - $draft = PhabricatorDraft::newFromUserAndKey($user, $macro->getPHID()); 68 + $draft = PhabricatorDraft::newFromUserAndKey($viewer, $macro->getPHID()); 75 69 76 70 $add_comment_form = id(new PhabricatorApplicationTransactionCommentView()) 77 - ->setUser($user) 71 + ->setUser($viewer) 78 72 ->setObjectPHID($macro->getPHID()) 79 73 ->setDraft($draft) 80 74 ->setHeaderText($comment_header)