2013-03-28 17:11:42 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PhortunePaymentMethodEditController
|
|
|
|
extends PhortuneController {
|
|
|
|
|
2014-08-11 21:07:35 +02:00
|
|
|
private $methodID;
|
2013-03-28 17:11:42 +01:00
|
|
|
|
|
|
|
public function willProcessRequest(array $data) {
|
2014-08-11 21:07:35 +02:00
|
|
|
$this->methodID = $data['id'];
|
2013-03-28 17:11:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function processRequest() {
|
|
|
|
$request = $this->getRequest();
|
2014-08-11 21:07:35 +02:00
|
|
|
$viewer = $request->getUser();
|
2013-03-28 17:11:42 +01:00
|
|
|
|
2014-08-11 21:07:35 +02:00
|
|
|
$method = id(new PhortunePaymentMethodQuery())
|
|
|
|
->setViewer($viewer)
|
|
|
|
->withIDs(array($this->methodID))
|
|
|
|
->requireCapabilities(
|
|
|
|
array(
|
|
|
|
PhabricatorPolicyCapability::CAN_VIEW,
|
|
|
|
PhabricatorPolicyCapability::CAN_EDIT,
|
|
|
|
))
|
2013-03-28 17:11:42 +01:00
|
|
|
->executeOne();
|
2014-08-11 21:07:35 +02:00
|
|
|
if (!$method) {
|
2013-03-28 17:11:42 +01:00
|
|
|
return new Aphront404Response();
|
|
|
|
}
|
|
|
|
|
2014-08-11 21:07:35 +02:00
|
|
|
$account = $method->getAccount();
|
2013-03-28 17:11:42 +01:00
|
|
|
$account_uri = $this->getApplicationURI($account->getID().'/');
|
|
|
|
|
2014-08-11 21:07:35 +02:00
|
|
|
if ($request->isFormPost()) {
|
2013-03-28 17:11:42 +01:00
|
|
|
|
2014-08-11 21:07:35 +02:00
|
|
|
$name = $request->getStr('name');
|
2014-07-13 18:18:50 +02:00
|
|
|
|
2014-08-11 21:07:35 +02:00
|
|
|
// TODO: Use ApplicationTransactions
|
2013-03-28 17:11:42 +01:00
|
|
|
|
2014-08-11 21:07:35 +02:00
|
|
|
$method->setName($name);
|
|
|
|
$method->save();
|
|
|
|
|
|
|
|
return id(new AphrontRedirectResponse())->setURI($account_uri);
|
2013-04-25 18:46:32 +02:00
|
|
|
}
|
2013-03-28 17:11:42 +01:00
|
|
|
|
2014-08-11 21:07:35 +02:00
|
|
|
$provider = $method->buildPaymentProvider();
|
2013-03-28 17:11:42 +01:00
|
|
|
|
2014-08-11 21:07:35 +02:00
|
|
|
$form = id(new AphrontFormView())
|
|
|
|
->setUser($viewer)
|
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormTextControl())
|
|
|
|
->setLabel(pht('Name'))
|
|
|
|
->setName('name')
|
|
|
|
->setValue($method->getName()))
|
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormStaticControl())
|
|
|
|
->setLabel(pht('Details'))
|
|
|
|
->setValue($method->getSummary()))
|
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormStaticControl())
|
|
|
|
->setLabel(pht('Expires'))
|
|
|
|
->setValue($method->getDisplayExpires()))
|
2013-04-25 18:46:32 +02:00
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormSubmitControl())
|
2014-08-11 21:07:35 +02:00
|
|
|
->addCancelButton($account_uri)
|
|
|
|
->setValue(pht('Save Changes')));
|
2013-03-28 17:11:42 +01:00
|
|
|
|
2014-07-13 18:18:50 +02:00
|
|
|
$box = id(new PHUIObjectBoxView())
|
2014-08-11 21:07:35 +02:00
|
|
|
->setHeaderText(pht('Edit Payment Method'))
|
[Redesign] Add Table, Collapse support to ObjectBox
Summary: Converts most all tables to be directly set via `setTable` to an ObjectBox. I think this path is more flexible design wise, as we can change the box based on children, and not just CSS. We also already do this with PropertyList, Forms, ObjectList, and Header. `setCollapsed` is added to ObjectBox to all children objects to bleed to the edges (like diffs).
Test Plan: I did a grep of `appendChild($table)` as well as searches for `PHUIObjectBoxView`, also with manual opening of hundreds of files. I'm sure I missed 5-8 places. If you just appendChild($table) nothing breaks, it just looks a little funny.
Reviewers: epriestley, btrahan
Subscribers: Korvin, epriestley
Differential Revision: https://secure.phabricator.com/D12955
2015-05-20 21:43:34 +02:00
|
|
|
->setForm($form);
|
2014-07-13 18:18:50 +02:00
|
|
|
|
|
|
|
$crumbs = $this->buildApplicationCrumbs();
|
2014-08-11 21:07:35 +02:00
|
|
|
$crumbs->addTextCrumb($account->getName(), $account_uri);
|
|
|
|
$crumbs->addTextCrumb($method->getDisplayName());
|
|
|
|
$crumbs->addTextCrumb(pht('Edit'));
|
2013-03-28 17:11:42 +01:00
|
|
|
|
2014-07-13 18:18:50 +02:00
|
|
|
return $this->buildApplicationPage(
|
|
|
|
array(
|
|
|
|
$crumbs,
|
|
|
|
$box,
|
|
|
|
),
|
|
|
|
array(
|
2014-08-11 21:07:35 +02:00
|
|
|
'title' => pht('Edit Payment Method'),
|
2014-07-13 18:18:50 +02:00
|
|
|
));
|
2013-04-25 18:46:32 +02:00
|
|
|
}
|
2013-03-28 17:11:42 +01:00
|
|
|
|
|
|
|
}
|