1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-20 12:30:56 +01:00

Update Nuance for handleRequest

Summary: Updates Nuance controllers

Test Plan: Read carefully, lint.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D13762
This commit is contained in:
Chad Little 2015-07-31 09:14:33 -07:00
parent 360eb85249
commit d902dd6589
4 changed files with 22 additions and 86 deletions

View file

@ -2,33 +2,16 @@
final class NuanceItemEditController extends NuanceController { final class NuanceItemEditController extends NuanceController {
private $itemID; public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
$id = $request->getURIData('id');
public function setItemID($item_id) { if (!$id) {
$this->itemID = $item_id;
return $this;
}
public function getItemID() {
return $this->itemID;
}
public function willProcessRequest(array $data) {
$this->setItemID(idx($data, 'id'));
}
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
$item_id = $this->getItemID();
$is_new = !$item_id;
if ($is_new) {
$item = new NuanceItem(); $item = new NuanceItem();
} else { } else {
$item = id(new NuanceItemQuery()) $item = id(new NuanceItemQuery())
->setViewer($user) ->setViewer($viewer)
->withIDs(array($item_id)) ->withIDs(array($id))
->executeOne(); ->executeOne();
} }

View file

@ -2,28 +2,13 @@
final class NuanceItemViewController extends NuanceController { final class NuanceItemViewController extends NuanceController {
private $itemID; public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
$id = $request->getURIData('id');
public function setItemID($item_id) {
$this->itemID = $item_id;
return $this;
}
public function getItemID() {
return $this->itemID;
}
public function willProcessRequest(array $data) {
$this->setItemID($data['id']);
}
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
$item_id = $this->getItemID();
$item = id(new NuanceItemQuery()) $item = id(new NuanceItemQuery())
->setViewer($user) ->setViewer($viewer)
->withIDs(array($item_id)) ->withIDs(array($id))
->executeOne(); ->executeOne();
if (!$item) { if (!$item) {

View file

@ -2,34 +2,17 @@
final class NuanceRequestorEditController extends NuanceController { final class NuanceRequestorEditController extends NuanceController {
private $requestorID; public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
$id = $request->getURIData('id');
public function setRequestorID($requestor_id) { if (!$id) {
$this->requestorID = $requestor_id;
return $this;
}
public function getRequestorID() {
return $this->requestorID;
}
public function willProcessRequest(array $data) {
$this->setRequestorID(idx($data, 'id'));
}
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
$requestor_id = $this->getRequestorID();
$is_new = !$requestor_id;
if ($is_new) {
$requestor = new NuanceRequestor(); $requestor = new NuanceRequestor();
} else { } else {
$requestor = id(new NuanceRequestorQuery()) $requestor = id(new NuanceRequestorQuery())
->setViewer($user) ->setViewer($viewer)
->withIDs(array($requestor_id)) ->withIDs(array($id))
->executeOne(); ->executeOne();
} }

View file

@ -2,28 +2,13 @@
final class NuanceRequestorViewController extends NuanceController { final class NuanceRequestorViewController extends NuanceController {
private $requestorID; public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
$id = $request->getURIData('id');
public function setRequestorID($requestor_id) {
$this->requestorID = $requestor_id;
return $this;
}
public function getRequestorID() {
return $this->requestorID;
}
public function willProcessRequest(array $data) {
$this->setRequestorID($data['id']);
}
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
$requestor_id = $this->getRequestorID();
$requestor = id(new NuanceRequestorQuery()) $requestor = id(new NuanceRequestorQuery())
->setViewer($user) ->setViewer($viewer)
->withIDs(array($requestor_id)) ->withIDs(array($id))
->executeOne(); ->executeOne();
if (!$requestor) { if (!$requestor) {