Remove all "FileHasObject" edge reads and writes
[phabricator.git] / src / applications / phortune / controller / account / PhortuneAccountPaymentMethodController.php
blob05a2f33d8d313d5facca8686dd6ad9d134496195
1 <?php
3 final class PhortuneAccountPaymentMethodController
4 extends PhortuneAccountProfileController {
6 protected function shouldRequireAccountEditCapability() {
7 return false;
10 protected function handleAccountRequest(AphrontRequest $request) {
11 $account = $this->getAccount();
12 $title = $account->getName();
14 $crumbs = $this->buildApplicationCrumbs()
15 ->addTextCrumb(pht('Payment Methods'))
16 ->setBorder(true);
18 $authority = $this->newAccountAuthorityView();
19 $header = $this->buildHeaderView();
20 $methods = $this->buildPaymentMethodsSection($account);
22 $view = id(new PHUITwoColumnView())
23 ->setHeader($header)
24 ->setFooter(
25 array(
26 $authority,
27 $methods,
28 ));
30 $navigation = $this->buildSideNavView('methods');
32 return $this->newPage()
33 ->setTitle($title)
34 ->setCrumbs($crumbs)
35 ->setNavigation($navigation)
36 ->appendChild($view);
39 private function buildPaymentMethodsSection(PhortuneAccount $account) {
40 $viewer = $this->getViewer();
42 $can_edit = PhabricatorPolicyFilter::hasCapability(
43 $viewer,
44 $account,
45 PhabricatorPolicyCapability::CAN_EDIT);
47 $id = $account->getID();
49 $add = id(new PHUIButtonView())
50 ->setTag('a')
51 ->setText(pht('Add Payment Method'))
52 ->setIcon('fa-plus')
53 ->setHref($this->getApplicationURI("account/{$id}/methods/new/"))
54 ->setDisabled(!$can_edit)
55 ->setWorkflow(!$can_edit);
57 $header = id(new PHUIHeaderView())
58 ->setHeader(pht('Payment Methods'))
59 ->addActionLink($add);
61 $list = id(new PHUIObjectItemListView())
62 ->setUser($viewer)
63 ->setFlush(true)
64 ->setNoDataString(
65 pht('There are no payment methods associated with this account.'));
67 $methods = id(new PhortunePaymentMethodQuery())
68 ->setViewer($viewer)
69 ->withAccountPHIDs(array($account->getPHID()))
70 ->withStatuses(
71 array(
72 PhortunePaymentMethod::STATUS_ACTIVE,
74 ->execute();
76 foreach ($methods as $method) {
77 $id = $method->getID();
79 $item = id(new PHUIObjectItemView())
80 ->setObjectName($method->getObjectName())
81 ->setHeader($method->getFullDisplayName())
82 ->setHref($method->getURI());
84 $provider = $method->buildPaymentProvider();
85 $item->addAttribute($provider->getPaymentMethodProviderDescription());
87 $list->addItem($item);
90 return id(new PHUIObjectBoxView())
91 ->setHeader($header)
92 ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
93 ->setObjectList($list);