From 02f42628c3bafd3fb8d893724dc8096f9b73c450 Mon Sep 17 00:00:00 2001 From: Chad Little Date: Mon, 12 Oct 2015 11:39:01 -0700 Subject: [PATCH] Update Harbormaster for handleRequest Summary: Updates Harbormaster for handleRequest over processRequest Test Plan: Went through various Harbormaster areas, buildables, actions. Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin Differential Revision: https://secure.phabricator.com/D14255 --- .../HarbormasterBuildActionController.php | 29 +++++++------------ .../HarbormasterBuildableActionController.php | 26 ++++++----------- .../HarbormasterBuildableListController.php | 10 ++----- .../HarbormasterPlanViewController.php | 1 - .../HarbormasterStepEditController.php | 2 +- 5 files changed, 22 insertions(+), 46 deletions(-) diff --git a/src/applications/harbormaster/controller/HarbormasterBuildActionController.php b/src/applications/harbormaster/controller/HarbormasterBuildActionController.php index 932a498a37..d729d868b0 100644 --- a/src/applications/harbormaster/controller/HarbormasterBuildActionController.php +++ b/src/applications/harbormaster/controller/HarbormasterBuildActionController.php @@ -3,24 +3,15 @@ final class HarbormasterBuildActionController extends HarbormasterController { - private $id; - private $action; - private $via; - - public function willProcessRequest(array $data) { - $this->id = $data['id']; - $this->action = $data['action']; - $this->via = idx($data, 'via'); - } - - public function processRequest() { - $request = $this->getRequest(); - $viewer = $request->getUser(); - $command = $this->action; + public function handleRequest(AphrontRequest $request) { + $viewer = $this->getViewer(); + $id = $request->getURIData('id'); + $action = $request->getURIData('action'); + $via = $request->getURIData('via'); $build = id(new HarbormasterBuildQuery()) ->setViewer($viewer) - ->withIDs(array($this->id)) + ->withIDs(array($id)) ->requireCapabilities( array( PhabricatorPolicyCapability::CAN_VIEW, @@ -31,7 +22,7 @@ final class HarbormasterBuildActionController return new Aphront404Response(); } - switch ($command) { + switch ($action) { case HarbormasterBuildCommand::COMMAND_RESTART: $can_issue = $build->canRestartBuild(); break; @@ -48,7 +39,7 @@ final class HarbormasterBuildActionController return new Aphront400Response(); } - switch ($this->via) { + switch ($via) { case 'buildable': $return_uri = '/'.$build->getBuildable()->getMonogram(); break; @@ -66,14 +57,14 @@ final class HarbormasterBuildActionController $xaction = id(new HarbormasterBuildTransaction()) ->setTransactionType(HarbormasterBuildTransaction::TYPE_COMMAND) - ->setNewValue($command); + ->setNewValue($action); $editor->applyTransactions($build, array($xaction)); return id(new AphrontRedirectResponse())->setURI($return_uri); } - switch ($command) { + switch ($action) { case HarbormasterBuildCommand::COMMAND_RESTART: if ($can_issue) { $title = pht('Really restart build?'); diff --git a/src/applications/harbormaster/controller/HarbormasterBuildableActionController.php b/src/applications/harbormaster/controller/HarbormasterBuildableActionController.php index 2716befd00..9fa7d6f006 100644 --- a/src/applications/harbormaster/controller/HarbormasterBuildableActionController.php +++ b/src/applications/harbormaster/controller/HarbormasterBuildableActionController.php @@ -3,22 +3,14 @@ final class HarbormasterBuildableActionController extends HarbormasterController { - 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(); - $command = $this->action; + public function handleRequest(AphrontRequest $request) { + $viewer = $this->getViewer(); + $id = $request->getURIData('id'); + $action = $request->getURIData('action'); $buildable = id(new HarbormasterBuildableQuery()) ->setViewer($viewer) - ->withIDs(array($this->id)) + ->withIDs(array($id)) ->needBuilds(true) ->requireCapabilities( array( @@ -33,7 +25,7 @@ final class HarbormasterBuildableActionController $issuable = array(); foreach ($buildable->getBuilds() as $build) { - switch ($command) { + switch ($action) { case HarbormasterBuildCommand::COMMAND_RESTART: if ($build->canRestartBuild()) { $issuable[] = $build; @@ -69,7 +61,7 @@ final class HarbormasterBuildableActionController $xaction = id(new HarbormasterBuildableTransaction()) ->setTransactionType(HarbormasterBuildableTransaction::TYPE_COMMAND) - ->setNewValue($command); + ->setNewValue($action); $editor->applyTransactions($buildable, array($xaction)); @@ -82,14 +74,14 @@ final class HarbormasterBuildableActionController foreach ($issuable as $build) { $xaction = id(new HarbormasterBuildTransaction()) ->setTransactionType(HarbormasterBuildTransaction::TYPE_COMMAND) - ->setNewValue($command); + ->setNewValue($action); $build_editor->applyTransactions($build, array($xaction)); } return id(new AphrontRedirectResponse())->setURI($return_uri); } - switch ($command) { + switch ($action) { case HarbormasterBuildCommand::COMMAND_RESTART: if ($issuable) { $title = pht('Really restart all builds?'); diff --git a/src/applications/harbormaster/controller/HarbormasterBuildableListController.php b/src/applications/harbormaster/controller/HarbormasterBuildableListController.php index aac41dc57b..b7e6dcd978 100644 --- a/src/applications/harbormaster/controller/HarbormasterBuildableListController.php +++ b/src/applications/harbormaster/controller/HarbormasterBuildableListController.php @@ -2,19 +2,13 @@ final class HarbormasterBuildableListController extends HarbormasterController { - private $queryKey; - public function shouldAllowPublic() { return true; } - public function willProcessRequest(array $data) { - $this->queryKey = idx($data, 'queryKey'); - } - - public function processRequest() { + public function handleRequest(AphrontRequest $request) { $controller = id(new PhabricatorApplicationSearchController()) - ->setQueryKey($this->queryKey) + ->setQueryKey($request->getURIData('queryKey')) ->setSearchEngine(new HarbormasterBuildableSearchEngine()) ->setNavigation($this->buildSideNavView()); diff --git a/src/applications/harbormaster/controller/HarbormasterPlanViewController.php b/src/applications/harbormaster/controller/HarbormasterPlanViewController.php index 95db4c52c0..680594277d 100644 --- a/src/applications/harbormaster/controller/HarbormasterPlanViewController.php +++ b/src/applications/harbormaster/controller/HarbormasterPlanViewController.php @@ -4,7 +4,6 @@ final class HarbormasterPlanViewController extends HarbormasterPlanController { public function handleRequest(AphrontRequest $request) { $viewer = $this->getviewer(); - $id = $request->getURIData('id'); $plan = id(new HarbormasterBuildPlanQuery()) diff --git a/src/applications/harbormaster/controller/HarbormasterStepEditController.php b/src/applications/harbormaster/controller/HarbormasterStepEditController.php index 089a801220..9e99cc6c7f 100644 --- a/src/applications/harbormaster/controller/HarbormasterStepEditController.php +++ b/src/applications/harbormaster/controller/HarbormasterStepEditController.php @@ -4,11 +4,11 @@ final class HarbormasterStepEditController extends HarbormasterController { public function handleRequest(AphrontRequest $request) { $viewer = $this->getViewer(); + $id = $request->getURIData('id'); $this->requireApplicationCapability( HarbormasterManagePlansCapability::CAPABILITY); - $id = $request->getURIData('id'); if ($id) { $step = id(new HarbormasterBuildStepQuery()) ->setViewer($viewer)