[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

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

   1  <?php
   2  
   3  final class PhortunePaymentMethodDisableController
   4    extends PhortuneController {
   5  
   6    private $methodID;
   7  
   8    public function willProcessRequest(array $data) {
   9      $this->methodID = $data['id'];
  10    }
  11  
  12    public function processRequest() {
  13      $request = $this->getRequest();
  14      $viewer = $request->getUser();
  15  
  16      $method = id(new PhortunePaymentMethodQuery())
  17        ->setViewer($viewer)
  18        ->withIDs(array($this->methodID))
  19        ->requireCapabilities(
  20          array(
  21            PhabricatorPolicyCapability::CAN_VIEW,
  22            PhabricatorPolicyCapability::CAN_EDIT,
  23          ))
  24        ->executeOne();
  25      if (!$method) {
  26        return new Aphront404Response();
  27      }
  28  
  29      if ($method->getStatus() == PhortunePaymentMethod::STATUS_DISABLED) {
  30        return new Aphront400Response();
  31      }
  32  
  33      $account = $method->getAccount();
  34      $account_uri = $this->getApplicationURI($account->getID().'/');
  35  
  36      if ($request->isFormPost()) {
  37  
  38        // TODO: ApplicationTransactions!
  39        $method
  40          ->setStatus(PhortunePaymentMethod::STATUS_DISABLED)
  41          ->save();
  42  
  43        return id(new AphrontRedirectResponse())->setURI($account_uri);
  44      }
  45  
  46      return $this->newDialog()
  47        ->setTitle(pht('Disable Payment Method?'))
  48        ->setShortTitle(pht('Disable Payment Method'))
  49        ->appendParagraph(
  50          pht(
  51            'Disable the payment method "%s"?',
  52            phutil_tag(
  53              'strong',
  54              array(),
  55              $method->getFullDisplayName())))
  56        ->appendParagraph(
  57          pht(
  58            'You will no longer be able to make payments using this payment '.
  59            'method. Disabled payment methods can not be reactivated.'))
  60        ->addCancelButton($account_uri)
  61        ->addSubmitButton(pht('Disable Payment Method'));
  62    }
  63  
  64  }


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