[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/phortune/controller/ -> PhortuneProviderActionController.php (source)

   1  <?php
   2  
   3  final class PhortuneProviderActionController
   4    extends PhortuneController {
   5  
   6    private $id;
   7    private $action;
   8  
   9    public function willProcessRequest(array $data) {
  10      $this->id = $data['id'];
  11      $this->setAction($data['action']);
  12    }
  13  
  14    public function setAction($action) {
  15      $this->action = $action;
  16      return $this;
  17    }
  18  
  19    public function getAction() {
  20      return $this->action;
  21    }
  22  
  23    public function processRequest() {
  24      $request = $this->getRequest();
  25      $viewer = $request->getUser();
  26  
  27      $provider_config = id(new PhortunePaymentProviderConfigQuery())
  28        ->setViewer($viewer)
  29        ->withIDs(array($this->id))
  30        ->executeOne();
  31      if (!$provider_config) {
  32        return new Aphront404Response();
  33      }
  34  
  35      $provider = $provider_config->buildProvider();
  36  
  37      if (!$provider->canRespondToControllerAction($this->getAction())) {
  38        return new Aphront404Response();
  39      }
  40  
  41      $response = $provider->processControllerRequest($this, $request);
  42  
  43      if ($response instanceof AphrontResponse) {
  44        return $response;
  45      }
  46  
  47      $title = 'Phortune';
  48  
  49      return $this->buildApplicationPage(
  50        $response,
  51        array(
  52          'title' => $title,
  53        ));
  54    }
  55  
  56  
  57    public function loadCart($id) {
  58      $request = $this->getRequest();
  59      $viewer = $request->getUser();
  60  
  61      return id(new PhortuneCartQuery())
  62        ->setViewer($viewer)
  63        ->needPurchases(true)
  64        ->withIDs(array($id))
  65        ->requireCapabilities(
  66          array(
  67            PhabricatorPolicyCapability::CAN_VIEW,
  68            PhabricatorPolicyCapability::CAN_EDIT,
  69          ))
  70        ->executeOne();
  71    }
  72  
  73    public function loadActiveCharge(PhortuneCart $cart) {
  74      $request = $this->getRequest();
  75      $viewer = $request->getUser();
  76  
  77      return id(new PhortuneChargeQuery())
  78        ->setViewer($viewer)
  79        ->withCartPHIDs(array($cart->getPHID()))
  80        ->withStatuses(
  81          array(
  82            PhortuneCharge::STATUS_CHARGING,
  83          ))
  84        ->executeOne();
  85    }
  86  
  87  }


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1