From c02615283308aab36974980a0a3de02032cf9ec9 Mon Sep 17 00:00:00 2001 From: Chad Little Date: Mon, 27 Jul 2015 07:56:52 -0700 Subject: [PATCH] Update Drydock for handleRequest Summary: Poked through the Drydock controllers and updated the codes. Test Plan: Built random fake stuff in Drydock Reviewers: epriestley Reviewed By: epriestley Subscribers: epriestley, Korvin Differential Revision: https://secure.phabricator.com/D13731 --- .../DrydockBlueprintCreateController.php | 5 ++--- .../DrydockBlueprintEditController.php | 18 ++++++----------- .../DrydockBlueprintListController.php | 10 +++------- .../DrydockBlueprintViewController.php | 14 ++++--------- .../controller/DrydockConsoleController.php | 5 ++--- .../controller/DrydockLeaseListController.php | 11 ++++------ .../DrydockLeaseReleaseController.php | 20 +++++++------------ .../controller/DrydockLeaseViewController.php | 14 ++++--------- .../controller/DrydockLogListController.php | 11 ++++------ .../DrydockResourceCloseController.php | 14 ++++--------- .../DrydockResourceListController.php | 11 ++++------ .../DrydockResourceViewController.php | 14 ++++--------- 12 files changed, 48 insertions(+), 99 deletions(-) diff --git a/src/applications/drydock/controller/DrydockBlueprintCreateController.php b/src/applications/drydock/controller/DrydockBlueprintCreateController.php index 56e0228077..5398a2327d 100644 --- a/src/applications/drydock/controller/DrydockBlueprintCreateController.php +++ b/src/applications/drydock/controller/DrydockBlueprintCreateController.php @@ -3,9 +3,8 @@ final class DrydockBlueprintCreateController extends DrydockBlueprintController { - public function processRequest() { - $request = $this->getRequest(); - $viewer = $request->getUser(); + public function handleRequest(AphrontRequest $request) { + $viewer = $request->getViewer(); $this->requireApplicationCapability( DrydockCreateBlueprintsCapability::CAPABILITY); diff --git a/src/applications/drydock/controller/DrydockBlueprintEditController.php b/src/applications/drydock/controller/DrydockBlueprintEditController.php index 4211c80b4c..1c75bf708d 100644 --- a/src/applications/drydock/controller/DrydockBlueprintEditController.php +++ b/src/applications/drydock/controller/DrydockBlueprintEditController.php @@ -2,20 +2,14 @@ final class DrydockBlueprintEditController extends DrydockBlueprintController { - private $id; + public function handleRequest(AphrontRequest $request) { + $viewer = $request->getViewer(); + $id = $request->getURIData('id'); - public function willProcessRequest(array $data) { - $this->id = idx($data, 'id'); - } - - public function processRequest() { - $request = $this->getRequest(); - $viewer = $request->getUser(); - - if ($this->id) { + if ($id) { $blueprint = id(new DrydockBlueprintQuery()) ->setViewer($viewer) - ->withIDs(array($this->id)) + ->withIDs(array($id)) ->requireCapabilities( array( PhabricatorPolicyCapability::CAN_VIEW, @@ -27,7 +21,7 @@ final class DrydockBlueprintEditController extends DrydockBlueprintController { } $impl = $blueprint->getImplementation(); - $cancel_uri = $this->getApplicationURI('blueprint/'.$this->id.'/'); + $cancel_uri = $this->getApplicationURI('blueprint/'.$id.'/'); } else { $this->requireApplicationCapability( DrydockCreateBlueprintsCapability::CAPABILITY); diff --git a/src/applications/drydock/controller/DrydockBlueprintListController.php b/src/applications/drydock/controller/DrydockBlueprintListController.php index 31e716691d..ff09f19ff8 100644 --- a/src/applications/drydock/controller/DrydockBlueprintListController.php +++ b/src/applications/drydock/controller/DrydockBlueprintListController.php @@ -2,20 +2,16 @@ final class DrydockBlueprintListController extends DrydockBlueprintController { - 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() { $request = $this->getRequest(); $controller = id(new PhabricatorApplicationSearchController()) - ->setQueryKey($this->queryKey) + ->setQueryKey($querykey) ->setSearchEngine(new DrydockBlueprintSearchEngine()) ->setNavigation($this->buildSideNavView()); diff --git a/src/applications/drydock/controller/DrydockBlueprintViewController.php b/src/applications/drydock/controller/DrydockBlueprintViewController.php index be5229972e..33a27264b8 100644 --- a/src/applications/drydock/controller/DrydockBlueprintViewController.php +++ b/src/applications/drydock/controller/DrydockBlueprintViewController.php @@ -2,19 +2,13 @@ final class DrydockBlueprintViewController extends DrydockBlueprintController { - 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'); $blueprint = id(new DrydockBlueprintQuery()) ->setViewer($viewer) - ->withIDs(array($this->id)) + ->withIDs(array($id)) ->executeOne(); if (!$blueprint) { return new Aphront404Response(); diff --git a/src/applications/drydock/controller/DrydockConsoleController.php b/src/applications/drydock/controller/DrydockConsoleController.php index fd2dff8ba5..118d49ea59 100644 --- a/src/applications/drydock/controller/DrydockConsoleController.php +++ b/src/applications/drydock/controller/DrydockConsoleController.php @@ -22,9 +22,8 @@ final class DrydockConsoleController extends DrydockController { return $nav; } - public function processRequest() { - $request = $this->getRequest(); - $viewer = $request->getUser(); + public function handleRequest(AphrontRequest $request) { + $viewer = $request->getViewer(); $menu = id(new PHUIObjectItemListView()) ->setUser($viewer); diff --git a/src/applications/drydock/controller/DrydockLeaseListController.php b/src/applications/drydock/controller/DrydockLeaseListController.php index f5c0897717..e370467a5f 100644 --- a/src/applications/drydock/controller/DrydockLeaseListController.php +++ b/src/applications/drydock/controller/DrydockLeaseListController.php @@ -2,19 +2,16 @@ final class DrydockLeaseListController extends DrydockLeaseController { - private $queryKey; - public function shouldAllowPublic() { return true; } - public function willProcessRequest(array $data) { - $this->queryKey = idx($data, 'queryKey'); - } + public function handleRequest(AphrontRequest $request) { + $viewer = $request->getViewer(); + $querykey = $request->getURIData('queryKey'); - public function processRequest() { $controller = id(new PhabricatorApplicationSearchController()) - ->setQueryKey($this->queryKey) + ->setQueryKey($querykey) ->setSearchEngine(new DrydockLeaseSearchEngine()) ->setNavigation($this->buildSideNavView()); diff --git a/src/applications/drydock/controller/DrydockLeaseReleaseController.php b/src/applications/drydock/controller/DrydockLeaseReleaseController.php index 1779edf1b2..4bac0330ba 100644 --- a/src/applications/drydock/controller/DrydockLeaseReleaseController.php +++ b/src/applications/drydock/controller/DrydockLeaseReleaseController.php @@ -2,19 +2,13 @@ final class DrydockLeaseReleaseController extends DrydockLeaseController { - private $id; - - public function willProcessRequest(array $data) { - $this->id = $data['id']; - } - - public function processRequest() { - $request = $this->getRequest(); - $user = $request->getUser(); + public function handleRequest(AphrontRequest $request) { + $viewer = $request->getViewer(); + $id = $request->getURIData('id'); $lease = id(new DrydockLeaseQuery()) - ->setViewer($user) - ->withIDs(array($this->id)) + ->setViewer($viewer) + ->withIDs(array($id)) ->executeOne(); if (!$lease) { return new Aphront404Response(); @@ -25,7 +19,7 @@ final class DrydockLeaseReleaseController extends DrydockLeaseController { if ($lease->getStatus() != DrydockLeaseStatus::STATUS_ACTIVE) { $dialog = id(new AphrontDialogView()) - ->setUser($user) + ->setUser($viewer) ->setTitle(pht('Lease Not Active')) ->appendChild( phutil_tag( @@ -39,7 +33,7 @@ final class DrydockLeaseReleaseController extends DrydockLeaseController { if (!$request->isDialogFormPost()) { $dialog = id(new AphrontDialogView()) - ->setUser($user) + ->setUser($viewer) ->setTitle(pht('Really release lease?')) ->appendChild( phutil_tag( diff --git a/src/applications/drydock/controller/DrydockLeaseViewController.php b/src/applications/drydock/controller/DrydockLeaseViewController.php index d597209b5a..92d215bcbb 100644 --- a/src/applications/drydock/controller/DrydockLeaseViewController.php +++ b/src/applications/drydock/controller/DrydockLeaseViewController.php @@ -2,19 +2,13 @@ final class DrydockLeaseViewController extends DrydockLeaseController { - 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'); $lease = id(new DrydockLeaseQuery()) ->setViewer($viewer) - ->withIDs(array($this->id)) + ->withIDs(array($id)) ->executeOne(); if (!$lease) { return new Aphront404Response(); diff --git a/src/applications/drydock/controller/DrydockLogListController.php b/src/applications/drydock/controller/DrydockLogListController.php index eaeb411d28..aecf77dc77 100644 --- a/src/applications/drydock/controller/DrydockLogListController.php +++ b/src/applications/drydock/controller/DrydockLogListController.php @@ -2,19 +2,16 @@ final class DrydockLogListController extends DrydockLogController { - private $queryKey; - public function shouldAllowPublic() { return true; } - public function willProcessRequest(array $data) { - $this->queryKey = idx($data, 'queryKey'); - } + public function handleRequest(AphrontRequest $request) { + $viewer = $request->getViewer(); + $querykey = $request->getURIData('queryKey'); - public function processRequest() { $controller = id(new PhabricatorApplicationSearchController()) - ->setQueryKey($this->queryKey) + ->setQueryKey($querykey) ->setSearchEngine(new DrydockLogSearchEngine()) ->setNavigation($this->buildSideNavView()); diff --git a/src/applications/drydock/controller/DrydockResourceCloseController.php b/src/applications/drydock/controller/DrydockResourceCloseController.php index 7963612ee4..915bf89452 100644 --- a/src/applications/drydock/controller/DrydockResourceCloseController.php +++ b/src/applications/drydock/controller/DrydockResourceCloseController.php @@ -2,19 +2,13 @@ final class DrydockResourceCloseController extends DrydockResourceController { - 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'); $resource = id(new DrydockResourceQuery()) ->setViewer($viewer) - ->withIDs(array($this->id)) + ->withIDs(array($id)) ->executeOne(); if (!$resource) { return new Aphront404Response(); diff --git a/src/applications/drydock/controller/DrydockResourceListController.php b/src/applications/drydock/controller/DrydockResourceListController.php index 53ed62a743..d2f34ec25b 100644 --- a/src/applications/drydock/controller/DrydockResourceListController.php +++ b/src/applications/drydock/controller/DrydockResourceListController.php @@ -2,19 +2,16 @@ final class DrydockResourceListController extends DrydockResourceController { - private $queryKey; - public function shouldAllowPublic() { return true; } - public function willProcessRequest(array $data) { - $this->queryKey = idx($data, 'queryKey'); - } + public function handleRequest(AphrontRequest $request) { + $viewer = $request->getViewer(); + $querykey = $request->getURIData('queryKey'); - public function processRequest() { $controller = id(new PhabricatorApplicationSearchController()) - ->setQueryKey($this->queryKey) + ->setQueryKey($querykey) ->setSearchEngine(new DrydockResourceSearchEngine()) ->setNavigation($this->buildSideNavView()); diff --git a/src/applications/drydock/controller/DrydockResourceViewController.php b/src/applications/drydock/controller/DrydockResourceViewController.php index 9be8188191..4cc7349dac 100644 --- a/src/applications/drydock/controller/DrydockResourceViewController.php +++ b/src/applications/drydock/controller/DrydockResourceViewController.php @@ -2,19 +2,13 @@ final class DrydockResourceViewController extends DrydockResourceController { - 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'); $resource = id(new DrydockResourceQuery()) ->setViewer($viewer) - ->withIDs(array($this->id)) + ->withIDs(array($id)) ->executeOne(); if (!$resource) { return new Aphront404Response();