From 6d59f3d1f2d41ce5f90d2ea10f3204353d543a01 Mon Sep 17 00:00:00 2001 From: Chad Little Date: Sat, 1 Aug 2015 15:41:36 -0700 Subject: [PATCH] Update Herald for handleRequest Summary: Update Herald for handleRequest Test Plan: New rule, test console, logs, lists. Reviewers: epriestley Reviewed By: epriestley Subscribers: epriestley, Korvin Maniphest Tasks: T8628 Differential Revision: https://secure.phabricator.com/D13765 --- .../controller/HeraldDisableController.php | 18 ++++--------- .../herald/controller/HeraldNewController.php | 5 ++-- .../controller/HeraldRuleController.php | 26 +++++++------------ .../controller/HeraldRuleListController.php | 10 +++---- .../controller/HeraldRuleViewController.php | 14 +++------- .../HeraldTestConsoleController.php | 15 ++++------- .../HeraldTranscriptListController.php | 10 +++---- 7 files changed, 31 insertions(+), 67 deletions(-) diff --git a/src/applications/herald/controller/HeraldDisableController.php b/src/applications/herald/controller/HeraldDisableController.php index edf15f80f6..054f30e7d3 100644 --- a/src/applications/herald/controller/HeraldDisableController.php +++ b/src/applications/herald/controller/HeraldDisableController.php @@ -2,18 +2,10 @@ final class HeraldDisableController extends HeraldController { - private $id; - private $action; - - public function willProcessRequest(array $data) { - $this->id = $data['id']; - $this->action = $data['action']; - } - - public function processRequest() { - $request = $this->getRequest(); - $viewer = $request->getUser(); - $id = $this->id; + public function handleRequest(AphrontRequest $request) { + $viewer = $request->getViewer(); + $id = $request->getURIData('id'); + $action = $request->getURIData('action'); $rule = id(new HeraldRuleQuery()) ->setViewer($viewer) @@ -35,7 +27,7 @@ final class HeraldDisableController extends HeraldController { $view_uri = $this->getApplicationURI("rule/{$id}/"); - $is_disable = ($this->action === 'disable'); + $is_disable = ($action === 'disable'); if ($request->isFormPost()) { $xaction = id(new HeraldRuleTransaction()) diff --git a/src/applications/herald/controller/HeraldNewController.php b/src/applications/herald/controller/HeraldNewController.php index 2bbc00456f..53e1faf7d6 100644 --- a/src/applications/herald/controller/HeraldNewController.php +++ b/src/applications/herald/controller/HeraldNewController.php @@ -2,9 +2,8 @@ final class HeraldNewController extends HeraldController { - public function processRequest() { - $request = $this->getRequest(); - $viewer = $request->getUser(); + public function handleRequest(AphrontRequest $request) { + $viewer = $request->getViewer(); $content_type_map = HeraldAdapter::getEnabledAdapterMap($viewer); $rule_type_map = HeraldRuleTypeConfig::getRuleTypeMap(); diff --git a/src/applications/herald/controller/HeraldRuleController.php b/src/applications/herald/controller/HeraldRuleController.php index 5f447abffd..385cb65d0d 100644 --- a/src/applications/herald/controller/HeraldRuleController.php +++ b/src/applications/herald/controller/HeraldRuleController.php @@ -2,24 +2,16 @@ final class HeraldRuleController extends HeraldController { - private $id; - private $filter; + public function handleRequest(AphrontRequest $request) { + $viewer = $request->getViewer(); + $id = $request->getURIData('id'); - public function willProcessRequest(array $data) { - $this->id = (int)idx($data, 'id'); - } - - public function processRequest() { - $request = $this->getRequest(); - $user = $request->getUser(); - - $content_type_map = HeraldAdapter::getEnabledAdapterMap($user); + $content_type_map = HeraldAdapter::getEnabledAdapterMap($viewer); $rule_type_map = HeraldRuleTypeConfig::getRuleTypeMap(); - if ($this->id) { - $id = $this->id; + if ($id) { $rule = id(new HeraldRuleQuery()) - ->setViewer($user) + ->setViewer($viewer) ->withIDs(array($id)) ->requireCapabilities( array( @@ -33,7 +25,7 @@ final class HeraldRuleController extends HeraldController { $cancel_uri = $this->getApplicationURI("rule/{$id}/"); } else { $rule = new HeraldRule(); - $rule->setAuthorPHID($user->getPHID()); + $rule->setAuthorPHID($viewer->getPHID()); $rule->setMustMatchAll(1); $content_type = $request->getStr('content_type'); @@ -58,7 +50,7 @@ final class HeraldRuleController extends HeraldController { if ($rule->isObjectRule()) { $rule->setTriggerObjectPHID($request->getStr('targetPHID')); $object = id(new PhabricatorObjectQuery()) - ->setViewer($user) + ->setViewer($viewer) ->withPHIDs(array($rule->getTriggerObjectPHID())) ->requireCapabilities( array( @@ -128,7 +120,7 @@ final class HeraldRuleController extends HeraldController { $rule_type_name = $rule_type_map[$rule->getRuleType()]; $form = id(new AphrontFormView()) - ->setUser($user) + ->setUser($viewer) ->setID('herald-rule-edit-form') ->addHiddenInput('content_type', $rule->getContentType()) ->addHiddenInput('rule_type', $rule->getRuleType()) diff --git a/src/applications/herald/controller/HeraldRuleListController.php b/src/applications/herald/controller/HeraldRuleListController.php index 8847b5d06b..490d84212d 100644 --- a/src/applications/herald/controller/HeraldRuleListController.php +++ b/src/applications/herald/controller/HeraldRuleListController.php @@ -2,19 +2,15 @@ final class HeraldRuleListController extends HeraldController { - private $queryKey; - public function shouldAllowPublic() { return true; } - public function willProcessRequest(array $data) { - $this->queryKey = idx($data, 'queryKey'); - } + public function handleRequest(AphrontRequest $request) { + $querykey = $request->getURIData('queryKey'); - public function processRequest() { $controller = id(new PhabricatorApplicationSearchController()) - ->setQueryKey($this->queryKey) + ->setQueryKey($querykey) ->setSearchEngine(new HeraldRuleSearchEngine()) ->setNavigation($this->buildSideNavView()); diff --git a/src/applications/herald/controller/HeraldRuleViewController.php b/src/applications/herald/controller/HeraldRuleViewController.php index f1ba8e44d7..f6ec235a9e 100644 --- a/src/applications/herald/controller/HeraldRuleViewController.php +++ b/src/applications/herald/controller/HeraldRuleViewController.php @@ -2,19 +2,13 @@ final class HeraldRuleViewController extends HeraldController { - private $id; - - public function willProcessRequest(array $data) { - $this->id = $data['id']; - } - - public function processRequest() { - $request = $this->getRequest(); - $viewer = $request->getUser(); + public function handleRequest(AphrontRequest $request) { + $viewer = $request->getViewer(); + $id = $request->getURIData('id'); $rule = id(new HeraldRuleQuery()) ->setViewer($viewer) - ->withIDs(array($this->id)) + ->withIDs(array($id)) ->needConditionsAndActions(true) ->executeOne(); if (!$rule) { diff --git a/src/applications/herald/controller/HeraldTestConsoleController.php b/src/applications/herald/controller/HeraldTestConsoleController.php index 7cd610f35a..a7741ba3ce 100644 --- a/src/applications/herald/controller/HeraldTestConsoleController.php +++ b/src/applications/herald/controller/HeraldTestConsoleController.php @@ -2,13 +2,8 @@ final class HeraldTestConsoleController extends HeraldController { - public function processRequest() { - - $request = $this->getRequest(); - $user = $request->getUser(); - - $request = $this->getRequest(); - + public function handleRequest(AphrontRequest $request) { + $viewer = $request->getViewer(); $object_name = trim($request->getStr('object_name')); $e_name = true; @@ -21,7 +16,7 @@ final class HeraldTestConsoleController extends HeraldController { if (!$errors) { $object = id(new PhabricatorObjectQuery()) - ->setViewer($user) + ->setViewer($viewer) ->withNames(array($object_name)) ->executeOne(); @@ -57,7 +52,7 @@ final class HeraldTestConsoleController extends HeraldController { $adapter->setIsNewObject(false); $rules = id(new HeraldRuleQuery()) - ->setViewer($user) + ->setViewer($viewer) ->withContentTypes(array($adapter->getAdapterContentType())) ->withDisabled(false) ->needConditionsAndActions(true) @@ -80,7 +75,7 @@ final class HeraldTestConsoleController extends HeraldController { } $form = id(new AphrontFormView()) - ->setUser($user) + ->setUser($viewer) ->appendRemarkupInstructions( pht( 'Enter an object to test rules for, like a Diffusion commit (e.g., '. diff --git a/src/applications/herald/controller/HeraldTranscriptListController.php b/src/applications/herald/controller/HeraldTranscriptListController.php index d53130d476..81865eee4a 100644 --- a/src/applications/herald/controller/HeraldTranscriptListController.php +++ b/src/applications/herald/controller/HeraldTranscriptListController.php @@ -2,8 +2,6 @@ final class HeraldTranscriptListController extends HeraldController { - private $queryKey; - public function buildSideNavView($for_app = false) { $user = $this->getRequest()->getUser(); @@ -32,13 +30,11 @@ final class HeraldTranscriptListController extends HeraldController { return $crumbs; } - public function willProcessRequest(array $data) { - $this->queryKey = idx($data, 'queryKey'); - } + public function handleRequest(AphrontRequest $request) { + $querykey = $request->getURIData('queryKey'); - public function processRequest() { $controller = id(new PhabricatorApplicationSearchController()) - ->setQueryKey($this->queryKey) + ->setQueryKey($querykey) ->setSearchEngine(new HeraldTranscriptSearchEngine()) ->setNavigation($this->buildSideNavView());