diff --git a/src/applications/flag/controller/PhabricatorFlagDeleteController.php b/src/applications/flag/controller/PhabricatorFlagDeleteController.php index cf1202c25..4dcb2cc37 100644 --- a/src/applications/flag/controller/PhabricatorFlagDeleteController.php +++ b/src/applications/flag/controller/PhabricatorFlagDeleteController.php @@ -1,29 +1,24 @@ <?php final class PhabricatorFlagDeleteController extends PhabricatorFlagController { - 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'); - $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(); } $flag->delete(); return id(new AphrontReloadResponse())->setURI('/flag/'); } } diff --git a/src/applications/flag/controller/PhabricatorFlagEditController.php b/src/applications/flag/controller/PhabricatorFlagEditController.php index b6e2327cd..5844a3801 100644 --- a/src/applications/flag/controller/PhabricatorFlagEditController.php +++ b/src/applications/flag/controller/PhabricatorFlagEditController.php @@ -1,93 +1,86 @@ <?php 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(); if (!$handle->isComplete()) { 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()) { $flag->setColor($request->getInt('color')); $flag->setNote($request->getStr('note')); $flag->save(); return id(new AphrontReloadResponse())->setURI('/flag/'); } $type_name = $handle->getTypeName(); $dialog = new AphrontDialogView(); - $dialog->setUser($user); + $dialog->setUser($viewer); $dialog->setTitle(pht('Flag %s', $type_name)); require_celerity_resource('phabricator-flag-css'); $form = new PHUIFormLayoutView(); $is_new = !$flag->getID(); if ($is_new) { $form ->appendChild(hsprintf( '<p>%s</p><br />', pht('You can flag this %s if you want to remember to look '. 'at it later.', $type_name))); } $radio = new AphrontFormRadioButtonControl(); foreach (PhabricatorFlagColor::getColorNameMap() as $color => $text) { $class = 'phabricator-flag-radio phabricator-flag-color-'.$color; $radio->addButton($color, $text, '', $class); } $form ->appendChild( $radio ->setName('color') ->setLabel(pht('Flag Color')) ->setValue($flag->getColor())) ->appendChild( id(new AphrontFormTextAreaControl()) ->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_SHORT) ->setName('note') ->setLabel(pht('Note')) ->setValue($flag->getNote())); $dialog->appendChild($form); $dialog->addCancelButton($handle->getURI()); $dialog->addSubmitButton( $is_new ? pht('Create Flag') : pht('Save')); return id(new AphrontDialogResponse())->setDialog($dialog); } } diff --git a/src/applications/flag/controller/PhabricatorFlagListController.php b/src/applications/flag/controller/PhabricatorFlagListController.php index 9029a35a7..88a6bcf7e 100644 --- a/src/applications/flag/controller/PhabricatorFlagListController.php +++ b/src/applications/flag/controller/PhabricatorFlagListController.php @@ -1,24 +1,21 @@ <?php 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()); return $this->delegateToController($controller); } }