From cdf03b0f7ae636560571c5d5027a467e3eb3872e Mon Sep 17 00:00:00 2001 From: Chad Little Date: Wed, 29 Jul 2015 17:00:31 -0700 Subject: [PATCH] Update Flag for handleRequest Summary: Updates Flag app for handleRequest Test Plan: Flag, Unflag, list flags, remove flag Reviewers: epriestley Reviewed By: epriestley Subscribers: epriestley, Korvin Differential Revision: https://secure.phabricator.com/D13757 --- .../PhabricatorFlagDeleteController.php | 15 ++++-------- .../PhabricatorFlagEditController.php | 23 +++++++------------ .../PhabricatorFlagListController.php | 11 ++++----- 3 files changed, 17 insertions(+), 32 deletions(-) diff --git a/src/applications/flag/controller/PhabricatorFlagDeleteController.php b/src/applications/flag/controller/PhabricatorFlagDeleteController.php index cf1202c251..4dcb2cc371 100644 --- a/src/applications/flag/controller/PhabricatorFlagDeleteController.php +++ b/src/applications/flag/controller/PhabricatorFlagDeleteController.php @@ -2,22 +2,17 @@ final class PhabricatorFlagDeleteController extends PhabricatorFlagController { - private $id; - public function willProcessRequest(array $data) { - $this->id = $data['id']; - } + public function handleRequest(AphrontRequest $request) { + $viewer = $request->getViewer(); + $id = $request->getURIData('id'); - public function processRequest() { - $request = $this->getRequest(); - $user = $request->getUser(); - - $flag = id(new PhabricatorFlag())->load($this->id); + $flag = id(new PhabricatorFlag())->load($id); if (!$flag) { return new Aphront404Response(); } - if ($flag->getOwnerPHID() != $user->getPHID()) { + if ($flag->getOwnerPHID() != $viewer->getPHID()) { return new Aphront400Response(); } diff --git a/src/applications/flag/controller/PhabricatorFlagEditController.php b/src/applications/flag/controller/PhabricatorFlagEditController.php index b6e2327cd4..5844a3801a 100644 --- a/src/applications/flag/controller/PhabricatorFlagEditController.php +++ b/src/applications/flag/controller/PhabricatorFlagEditController.php @@ -2,19 +2,12 @@ final class PhabricatorFlagEditController extends PhabricatorFlagController { - private $phid; + public function handleRequest(AphrontRequest $request) { + $viewer = $request->getViewer(); + $phid = $request->getURIData('phid'); - public function willProcessRequest(array $data) { - $this->phid = $data['phid']; - } - - public function processRequest() { - $request = $this->getRequest(); - $user = $request->getUser(); - - $phid = $this->phid; $handle = id(new PhabricatorHandleQuery()) - ->setViewer($user) + ->setViewer($viewer) ->withPHIDs(array($phid)) ->executeOne(); @@ -22,14 +15,14 @@ final class PhabricatorFlagEditController extends PhabricatorFlagController { return new Aphront404Response(); } - $flag = PhabricatorFlagQuery::loadUserFlag($user, $phid); + $flag = PhabricatorFlagQuery::loadUserFlag($viewer, $phid); if (!$flag) { $flag = new PhabricatorFlag(); - $flag->setOwnerPHID($user->getPHID()); + $flag->setOwnerPHID($viewer->getPHID()); $flag->setType($handle->getType()); $flag->setObjectPHID($handle->getPHID()); - $flag->setReasonPHID($user->getPHID()); + $flag->setReasonPHID($viewer->getPHID()); } if ($request->isDialogFormPost()) { @@ -43,7 +36,7 @@ final class PhabricatorFlagEditController extends PhabricatorFlagController { $type_name = $handle->getTypeName(); $dialog = new AphrontDialogView(); - $dialog->setUser($user); + $dialog->setUser($viewer); $dialog->setTitle(pht('Flag %s', $type_name)); diff --git a/src/applications/flag/controller/PhabricatorFlagListController.php b/src/applications/flag/controller/PhabricatorFlagListController.php index 9029a35a7e..88a6bcf7e0 100644 --- a/src/applications/flag/controller/PhabricatorFlagListController.php +++ b/src/applications/flag/controller/PhabricatorFlagListController.php @@ -2,19 +2,16 @@ final class PhabricatorFlagListController extends PhabricatorFlagController { - 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 PhabricatorFlagSearchEngine()) ->setNavigation($this->buildSideNavView());