1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-19 21:32:43 +01:00

Update Phortune for handleRequest

Summary: Updates Phortune controllers for handleRequest

Test Plan: New Invoice, new merchant, new subscriptions, manual bill, pay bill, anything I could find to test.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: epriestley, Korvin

Maniphest Tasks: T8628

Differential Revision: https://secure.phabricator.com/D13768
This commit is contained in:
Chad Little 2015-08-01 15:43:47 -07:00
parent 2ff4601584
commit 1d2c47f110
21 changed files with 104 additions and 215 deletions

View file

@ -2,20 +2,14 @@
final class PhortuneAccountEditController extends PhortuneController {
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) {
$account = id(new PhortuneAccountQuery())
->setViewer($viewer)
->withIDs(array($this->id))
->withIDs(array($id))
->requireCapabilities(
array(
PhabricatorPolicyCapability::CAN_VIEW,

View file

@ -2,9 +2,8 @@
final class PhortuneAccountListController extends PhortuneController {
public function processRequest() {
$request = $this->getRequest();
$viewer = $request->getUser();
public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
$accounts = id(new PhortuneAccountQuery())
->setViewer($viewer)

View file

@ -3,15 +3,9 @@
final class PhortuneCartAcceptController
extends PhortuneCartController {
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');
// You must control the merchant to accept orders.
$authority = $this->loadMerchantAuthority();
@ -21,7 +15,7 @@ final class PhortuneCartAcceptController
$cart = id(new PhortuneCartQuery())
->setViewer($viewer)
->withIDs(array($this->id))
->withIDs(array($id))
->withMerchantPHIDs(array($authority->getPHID()))
->needPurchases(true)
->executeOne();

View file

@ -3,23 +3,16 @@
final class PhortuneCartCancelController
extends PhortuneCartController {
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();
public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
$id = $request->getURIData('id');
$action = $request->getURIData('action');
$authority = $this->loadMerchantAuthority();
$cart_query = id(new PhortuneCartQuery())
->setViewer($viewer)
->withIDs(array($this->id))
->withIDs(array($id))
->needPurchases(true);
if ($authority) {
@ -31,7 +24,7 @@ final class PhortuneCartCancelController
return new Aphront404Response();
}
switch ($this->action) {
switch ($action) {
case 'cancel':
// You must be able to edit the account to cancel an order.
PhabricatorPolicyFilter::requireCapability(

View file

@ -3,19 +3,13 @@
final class PhortuneCartCheckoutController
extends PhortuneCartController {
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');
$cart = id(new PhortuneCartQuery())
->setViewer($viewer)
->withIDs(array($this->id))
->withIDs(array($id))
->needPurchases(true)
->executeOne();
if (!$cart) {

View file

@ -3,21 +3,15 @@
final class PhortuneCartUpdateController
extends PhortuneCartController {
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');
$authority = $this->loadMerchantAuthority();
$cart_query = id(new PhortuneCartQuery())
->setViewer($viewer)
->withIDs(array($this->id))
->withIDs(array($id))
->needPurchases(true);
if ($authority) {

View file

@ -3,21 +3,15 @@
final class PhortuneCartViewController
extends PhortuneCartController {
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');
$authority = $this->loadMerchantAuthority();
$query = id(new PhortuneCartQuery())
->setViewer($viewer)
->withIDs(array($this->id))
->withIDs(array($id))
->needPurchases(true);
if ($authority) {

View file

@ -3,26 +3,19 @@
final class PhortuneChargeListController
extends PhortuneController {
private $accountID;
private $queryKey;
private $account;
public function willProcessRequest(array $data) {
$this->accountID = idx($data, 'accountID');
$this->queryKey = idx($data, 'queryKey');
}
public function processRequest() {
$request = $this->getRequest();
$viewer = $request->getUser();
public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
$querykey = $request->getURIData('queryKey');
$account_id = $request->getURIData('accountID');
$engine = new PhortuneChargeSearchEngine();
if ($this->accountID) {
if ($account_id) {
$account = id(new PhortuneAccountQuery())
->setViewer($viewer)
->withIDs(array($this->accountID))
->withIDs(array($account_id))
->requireCapabilities(
array(
PhabricatorPolicyCapability::CAN_VIEW,
@ -39,7 +32,7 @@ final class PhortuneChargeListController
}
$controller = id(new PhabricatorApplicationSearchController())
->setQueryKey($this->queryKey)
->setQueryKey($querykey)
->setSearchEngine($engine)
->setNavigation($this->buildSideNavView());
@ -47,7 +40,7 @@ final class PhortuneChargeListController
}
public function buildSideNavView() {
$viewer = $this->getRequest()->getUser();
$viewer = $this->getViewer();
$nav = new AphrontSideNavFilterView();
$nav->setBaseURI(new PhutilURI($this->getApplicationURI()));

View file

@ -2,18 +2,17 @@
final class PhortuneLandingController extends PhortuneController {
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
$accounts = id(new PhortuneAccountQuery())
->setViewer($user)
->withMemberPHIDs(array($user->getPHID()))
->setViewer($viewer)
->withMemberPHIDs(array($viewer->getPHID()))
->execute();
if (!$accounts) {
$account = PhortuneAccount::createNewAccount(
$user,
$viewer,
PhabricatorContentSource::newFromRequest($request));
$accounts = array($account);
}

View file

@ -3,20 +3,14 @@
final class PhortuneMerchantEditController
extends PhortuneMerchantController {
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) {
$merchant = id(new PhortuneMerchantQuery())
->setViewer($viewer)
->withIDs(array($this->id))
->withIDs(array($id))
->requireCapabilities(
array(
PhabricatorPolicyCapability::CAN_VIEW,

View file

@ -3,19 +3,16 @@
final class PhortuneMerchantListController
extends PhortuneMerchantController {
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 PhortuneMerchantSearchEngine())
->setNavigation($this->buildSideNavView());
@ -23,7 +20,7 @@ final class PhortuneMerchantListController
}
public function buildSideNavView() {
$viewer = $this->getRequest()->getUser();
$viewer = $this->getViewer();
$nav = new AphrontSideNavFilterView();
$nav->setBaseURI(new PhutilURI($this->getApplicationURI()));

View file

@ -3,19 +3,13 @@
final class PhortuneMerchantViewController
extends PhortuneMerchantController {
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');
$merchant = id(new PhortuneMerchantQuery())
->setViewer($viewer)
->withIDs(array($this->id))
->withIDs(array($id))
->executeOne();
if (!$merchant) {
return new Aphront404Response();

View file

@ -3,19 +3,13 @@
final class PhortunePaymentMethodCreateController
extends PhortuneController {
private $accountID;
public function willProcessRequest(array $data) {
$this->accountID = $data['accountID'];
}
public function processRequest() {
$request = $this->getRequest();
$viewer = $request->getUser();
public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
$account_id = $request->getURIData('accountID');
$account = id(new PhortuneAccountQuery())
->setViewer($viewer)
->withIDs(array($this->accountID))
->withIDs(array($account_id))
->executeOne();
if (!$account) {
return new Aphront404Response();

View file

@ -3,19 +3,13 @@
final class PhortunePaymentMethodDisableController
extends PhortuneController {
private $methodID;
public function willProcessRequest(array $data) {
$this->methodID = $data['id'];
}
public function processRequest() {
$request = $this->getRequest();
$viewer = $request->getUser();
public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
$method_id = $request->getURIData('methodID');
$method = id(new PhortunePaymentMethodQuery())
->setViewer($viewer)
->withIDs(array($this->methodID))
->withIDs(array($method_id))
->requireCapabilities(
array(
PhabricatorPolicyCapability::CAN_VIEW,

View file

@ -3,19 +3,13 @@
final class PhortunePaymentMethodEditController
extends PhortuneController {
private $methodID;
public function willProcessRequest(array $data) {
$this->methodID = $data['id'];
}
public function processRequest() {
$request = $this->getRequest();
$viewer = $request->getUser();
public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
$method_id = $request->getURIData('id');
$method = id(new PhortunePaymentMethodQuery())
->setViewer($viewer)
->withIDs(array($this->methodID))
->withIDs(array($method_id))
->requireCapabilities(
array(
PhabricatorPolicyCapability::CAN_VIEW,

View file

@ -2,15 +2,14 @@
final class PhortuneProductListController extends PhabricatorController {
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
$pager = new AphrontCursorPagerView();
$pager->readFromRequest($request);
$query = id(new PhortuneProductQuery())
->setViewer($user);
->setViewer($viewer);
$products = $query->executeWithCursorPager($pager);
@ -27,7 +26,7 @@ final class PhortuneProductListController extends PhabricatorController {
->setIcon('fa-plus-square'));
$product_list = id(new PHUIObjectItemListView())
->setUser($user)
->setUser($viewer)
->setNoDataString(pht('No products.'));
foreach ($products as $product) {

View file

@ -2,19 +2,13 @@
final class PhortuneProductViewController extends PhortuneController {
private $productID;
public function willProcessRequest(array $data) {
$this->productID = $data['id'];
}
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
$id = $request->getURIData('id');
$product = id(new PhortuneProductQuery())
->setViewer($user)
->withIDs(array($this->productID))
->setViewer($viewer)
->withIDs(array($id))
->executeOne();
if (!$product) {
return new Aphront404Response();
@ -28,7 +22,7 @@ final class PhortuneProductViewController extends PhortuneController {
$edit_uri = $this->getApplicationURI('product/edit/'.$product->getID().'/');
$actions = id(new PhabricatorActionListView())
->setUser($user)
->setUser($viewer)
->setObjectURI($request->getRequestURI());
$crumbs = $this->buildApplicationCrumbs();
@ -40,7 +34,7 @@ final class PhortuneProductViewController extends PhortuneController {
$request->getRequestURI());
$properties = id(new PHUIPropertyListView())
->setUser($user)
->setUser($viewer)
->setActionList($actions)
->addProperty(
pht('Price'),

View file

@ -3,14 +3,8 @@
final class PhortuneProviderActionController
extends PhortuneController {
private $id;
private $action;
public function willProcessRequest(array $data) {
$this->id = $data['id'];
$this->setAction($data['action']);
}
public function setAction($action) {
$this->action = $action;
return $this;
@ -20,13 +14,14 @@ final class PhortuneProviderActionController
return $this->action;
}
public function processRequest() {
$request = $this->getRequest();
$viewer = $request->getUser();
public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
$id = $request->getURIData('id');
$this->setAction($request->getURIData('action'));
$provider_config = id(new PhortunePaymentProviderConfigQuery())
->setViewer($viewer)
->withIDs(array($this->id))
->withIDs(array($id))
->executeOne();
if (!$provider_config) {
return new Aphront404Response();

View file

@ -3,19 +3,13 @@
final class PhortuneProviderDisableController
extends PhortuneMerchantController {
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');
$provider_config = id(new PhortunePaymentProviderConfigQuery())
->setViewer($viewer)
->withIDs(array($this->id))
->withIDs(array($id))
->requireCapabilities(
array(
PhabricatorPolicyCapability::CAN_VIEW,

View file

@ -3,20 +3,14 @@
final class PhortuneProviderEditController
extends PhortuneMerchantController {
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) {
$provider_config = id(new PhortunePaymentProviderConfigQuery())
->setViewer($viewer)
->withIDs(array($this->id))
->withIDs(array($id))
->requireCapabilities(
array(
PhabricatorPolicyCapability::CAN_VIEW,

View file

@ -3,29 +3,21 @@
final class PhortuneSubscriptionListController
extends PhortuneController {
private $accountID;
private $merchantID;
private $queryKey;
private $merchant;
private $account;
public function willProcessRequest(array $data) {
$this->merchantID = idx($data, 'merchantID');
$this->accountID = idx($data, 'accountID');
$this->queryKey = idx($data, 'queryKey');
}
public function processRequest() {
$request = $this->getRequest();
$viewer = $request->getUser();
public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
$querykey = $request->getURIData('queryKey');
$merchant_id = $request->getURIData('merchantID');
$account_id = $request->getURIData('accountID');
$engine = new PhortuneSubscriptionSearchEngine();
if ($this->merchantID) {
if ($merchant_id) {
$merchant = id(new PhortuneMerchantQuery())
->setViewer($viewer)
->withIDs(array($this->merchantID))
->withIDs(array($merchant_id))
->requireCapabilities(
array(
PhabricatorPolicyCapability::CAN_VIEW,
@ -38,10 +30,10 @@ final class PhortuneSubscriptionListController
$this->merchant = $merchant;
$viewer->grantAuthority($merchant);
$engine->setMerchant($merchant);
} else if ($this->accountID) {
} else if ($account_id) {
$account = id(new PhortuneAccountQuery())
->setViewer($viewer)
->withIDs(array($this->accountID))
->withIDs(array($account_id))
->requireCapabilities(
array(
PhabricatorPolicyCapability::CAN_VIEW,
@ -58,7 +50,7 @@ final class PhortuneSubscriptionListController
}
$controller = id(new PhabricatorApplicationSearchController())
->setQueryKey($this->queryKey)
->setQueryKey($querykey)
->setSearchEngine($engine)
->setNavigation($this->buildSideNavView());
@ -66,7 +58,7 @@ final class PhortuneSubscriptionListController
}
public function buildSideNavView() {
$viewer = $this->getRequest()->getUser();
$viewer = $this->getViewer();
$nav = new AphrontSideNavFilterView();
$nav->setBaseURI(new PhutilURI($this->getApplicationURI()));