Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / phortune / controller / provider / PhortuneProviderActionController.php
blob4d9b9f83866b7657af9352f6214d865c33b46040
1 <?php
3 final class PhortuneProviderActionController
4 extends PhortuneController {
6 private $action;
8 public function setAction($action) {
9 $this->action = $action;
10 return $this;
13 public function getAction() {
14 return $this->action;
17 public function handleRequest(AphrontRequest $request) {
18 $viewer = $request->getViewer();
19 $id = $request->getURIData('id');
20 $this->setAction($request->getURIData('action'));
22 $provider_config = id(new PhortunePaymentProviderConfigQuery())
23 ->setViewer($viewer)
24 ->withIDs(array($id))
25 ->executeOne();
26 if (!$provider_config) {
27 return new Aphront404Response();
30 $provider = $provider_config->buildProvider();
32 if (!$provider->canRespondToControllerAction($this->getAction())) {
33 return new Aphront404Response();
36 $response = $provider->processControllerRequest($this, $request);
38 if ($response instanceof AphrontResponse) {
39 return $response;
42 $title = pht('Phortune');
44 return $this->newPage()
45 ->setTitle($title)
46 ->appendChild($response);
51 public function loadCart($id) {
52 $request = $this->getRequest();
53 $viewer = $request->getUser();
55 return id(new PhortuneCartQuery())
56 ->setViewer($viewer)
57 ->needPurchases(true)
58 ->withIDs(array($id))
59 ->requireCapabilities(
60 array(
61 PhabricatorPolicyCapability::CAN_VIEW,
62 PhabricatorPolicyCapability::CAN_EDIT,
64 ->executeOne();
67 public function loadActiveCharge(PhortuneCart $cart) {
68 $request = $this->getRequest();
69 $viewer = $request->getUser();
71 return id(new PhortuneChargeQuery())
72 ->setViewer($viewer)
73 ->withCartPHIDs(array($cart->getPHID()))
74 ->withStatuses(
75 array(
76 PhortuneCharge::STATUS_CHARGING,
78 ->executeOne();