Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14638671
D20715.id49432.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
10 KB
Referenced Files
None
Subscribers
None
D20715.id49432.diff
View Options
diff --git a/resources/sql/autopatches/20190815.account.01.carts.php b/resources/sql/autopatches/20190815.account.01.carts.php
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20190815.account.01.carts.php
@@ -0,0 +1,10 @@
+<?php
+
+$edge_type = PhortuneAccountHasMerchantEdgeType::EDGECONST;
+
+$table = new PhortuneCart();
+foreach (new LiskMigrationIterator($table) as $cart) {
+ id(new PhabricatorEdgeEditor())
+ ->addEdge($cart->getAccountPHID(), $edge_type, $cart->getMerchantPHID())
+ ->save();
+}
diff --git a/resources/sql/autopatches/20190815.account.02.subscriptions.php b/resources/sql/autopatches/20190815.account.02.subscriptions.php
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20190815.account.02.subscriptions.php
@@ -0,0 +1,10 @@
+<?php
+
+$edge_type = PhortuneAccountHasMerchantEdgeType::EDGECONST;
+
+$table = new PhortuneSubscription();
+foreach (new LiskMigrationIterator($table) as $sub) {
+ id(new PhabricatorEdgeEditor())
+ ->addEdge($sub->getAccountPHID(), $edge_type, $sub->getMerchantPHID())
+ ->save();
+}
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -5243,6 +5243,7 @@
'PhortuneAccountEmailTransactionType' => 'applications/phortune/xaction/PhortuneAccountEmailTransactionType.php',
'PhortuneAccountEmailViewController' => 'applications/phortune/controller/account/PhortuneAccountEmailViewController.php',
'PhortuneAccountHasMemberEdgeType' => 'applications/phortune/edge/PhortuneAccountHasMemberEdgeType.php',
+ 'PhortuneAccountHasMerchantEdgeType' => 'applications/phortune/edge/PhortuneAccountHasMerchantEdgeType.php',
'PhortuneAccountListController' => 'applications/phortune/controller/account/PhortuneAccountListController.php',
'PhortuneAccountManagersController' => 'applications/phortune/controller/account/PhortuneAccountManagersController.php',
'PhortuneAccountNameTransaction' => 'applications/phortune/xaction/PhortuneAccountNameTransaction.php',
@@ -5302,6 +5303,7 @@
'PhortuneMerchantEditController' => 'applications/phortune/controller/merchant/PhortuneMerchantEditController.php',
'PhortuneMerchantEditEngine' => 'applications/phortune/editor/PhortuneMerchantEditEngine.php',
'PhortuneMerchantEditor' => 'applications/phortune/editor/PhortuneMerchantEditor.php',
+ 'PhortuneMerchantHasAccountEdgeType' => 'applications/phortune/edge/PhortuneMerchantHasAccountEdgeType.php',
'PhortuneMerchantHasMemberEdgeType' => 'applications/phortune/edge/PhortuneMerchantHasMemberEdgeType.php',
'PhortuneMerchantInvoiceCreateController' => 'applications/phortune/controller/merchant/PhortuneMerchantInvoiceCreateController.php',
'PhortuneMerchantInvoiceEmailTransaction' => 'applications/phortune/xaction/PhortuneMerchantInvoiceEmailTransaction.php',
@@ -11796,6 +11798,7 @@
'PhortuneAccountEmailTransactionType' => 'PhabricatorModularTransactionType',
'PhortuneAccountEmailViewController' => 'PhortuneAccountController',
'PhortuneAccountHasMemberEdgeType' => 'PhabricatorEdgeType',
+ 'PhortuneAccountHasMerchantEdgeType' => 'PhabricatorEdgeType',
'PhortuneAccountListController' => 'PhortuneController',
'PhortuneAccountManagersController' => 'PhortuneAccountProfileController',
'PhortuneAccountNameTransaction' => 'PhortuneAccountTransactionType',
@@ -11866,6 +11869,7 @@
'PhortuneMerchantEditController' => 'PhortuneMerchantController',
'PhortuneMerchantEditEngine' => 'PhabricatorEditEngine',
'PhortuneMerchantEditor' => 'PhabricatorApplicationTransactionEditor',
+ 'PhortuneMerchantHasAccountEdgeType' => 'PhabricatorEdgeType',
'PhortuneMerchantHasMemberEdgeType' => 'PhabricatorEdgeType',
'PhortuneMerchantInvoiceCreateController' => 'PhortuneMerchantProfileController',
'PhortuneMerchantInvoiceEmailTransaction' => 'PhortuneMerchantTransactionType',
diff --git a/src/applications/phortune/controller/account/PhortuneAccountDetailsController.php b/src/applications/phortune/controller/account/PhortuneAccountDetailsController.php
--- a/src/applications/phortune/controller/account/PhortuneAccountDetailsController.php
+++ b/src/applications/phortune/controller/account/PhortuneAccountDetailsController.php
@@ -97,6 +97,28 @@
->setHeaderText(pht('Managers'))
->appendChild($member_list);
+ $merchant_list = id(new PHUIObjectItemListView())
+ ->setSimple(true)
+ ->setNoDataString(pht('No purchase history.'));
+
+ $merchant_phids = $account->getMerchantPHIDs();
+ $handles = $viewer->loadHandles($merchant_phids);
+
+ foreach ($merchant_phids as $merchant_phid) {
+ $handle = $handles[$merchant_phid];
+
+ $merchant = id(new PHUIObjectItemView())
+ ->setImageURI($handle->getImageURI())
+ ->setHref($handle->getURI())
+ ->setHeader($handle->getFullName());
+
+ $merchant_list->addItem($merchant);
+ }
+
+ $curtain->newPanel()
+ ->setHeaderText(pht('Merchants'))
+ ->appendChild($merchant_list);
+
return $curtain;
}
diff --git a/src/applications/phortune/edge/PhortuneAccountHasMerchantEdgeType.php b/src/applications/phortune/edge/PhortuneAccountHasMerchantEdgeType.php
new file mode 100644
--- /dev/null
+++ b/src/applications/phortune/edge/PhortuneAccountHasMerchantEdgeType.php
@@ -0,0 +1,11 @@
+<?php
+
+final class PhortuneAccountHasMerchantEdgeType
+ extends PhabricatorEdgeType {
+
+ const EDGECONST = 73;
+
+ public function getInverseEdgeConstant() {
+ return PhortuneMerchantHasAccountEdgeType::EDGECONST;
+ }
+}
diff --git a/src/applications/phortune/edge/PhortuneMerchantHasAccountEdgeType.php b/src/applications/phortune/edge/PhortuneMerchantHasAccountEdgeType.php
new file mode 100644
--- /dev/null
+++ b/src/applications/phortune/edge/PhortuneMerchantHasAccountEdgeType.php
@@ -0,0 +1,12 @@
+<?php
+
+final class PhortuneMerchantHasAccountEdgeType
+ extends PhabricatorEdgeType {
+
+ const EDGECONST = 74;
+
+ public function getInverseEdgeConstant() {
+ return PhortuneAccountHasMerchantEdgeType::EDGECONST;
+ }
+
+}
diff --git a/src/applications/phortune/editor/PhortuneCartEditor.php b/src/applications/phortune/editor/PhortuneCartEditor.php
--- a/src/applications/phortune/editor/PhortuneCartEditor.php
+++ b/src/applications/phortune/editor/PhortuneCartEditor.php
@@ -235,4 +235,16 @@
return $this;
}
+ protected function applyFinalEffects(
+ PhabricatorLiskDAO $object,
+ array $xactions) {
+
+ $account = $object->getAccount();
+ $merchant = $object->getMerchant();
+ $account->writeMerchantEdge($merchant);
+
+ return $xactions;
+ }
+
+
}
diff --git a/src/applications/phortune/phid/PhortuneMerchantPHIDType.php b/src/applications/phortune/phid/PhortuneMerchantPHIDType.php
--- a/src/applications/phortune/phid/PhortuneMerchantPHIDType.php
+++ b/src/applications/phortune/phid/PhortuneMerchantPHIDType.php
@@ -21,7 +21,8 @@
array $phids) {
return id(new PhortuneMerchantQuery())
- ->withPHIDs($phids);
+ ->withPHIDs($phids)
+ ->needProfileImage(true);
}
public function loadHandles(
@@ -32,10 +33,10 @@
foreach ($handles as $phid => $handle) {
$merchant = $objects[$phid];
- $id = $merchant->getID();
-
- $handle->setName($merchant->getName());
- $handle->setURI("/phortune/merchant/{$id}/");
+ $handle
+ ->setName($merchant->getName())
+ ->setURI($merchant->getURI())
+ ->setImageURI($merchant->getProfileImageURI());
}
}
diff --git a/src/applications/phortune/query/PhortuneAccountQuery.php b/src/applications/phortune/query/PhortuneAccountQuery.php
--- a/src/applications/phortune/query/PhortuneAccountQuery.php
+++ b/src/applications/phortune/query/PhortuneAccountQuery.php
@@ -53,13 +53,34 @@
protected function willFilterPage(array $accounts) {
$query = id(new PhabricatorEdgeQuery())
->withSourcePHIDs(mpull($accounts, 'getPHID'))
- ->withEdgeTypes(array(PhortuneAccountHasMemberEdgeType::EDGECONST));
+ ->withEdgeTypes(
+ array(
+ PhortuneAccountHasMemberEdgeType::EDGECONST,
+ PhortuneAccountHasMerchantEdgeType::EDGECONST,
+ ));
+
$query->execute();
foreach ($accounts as $account) {
- $member_phids = $query->getDestinationPHIDs(array($account->getPHID()));
+ $member_phids = $query->getDestinationPHIDs(
+ array(
+ $account->getPHID(),
+ ),
+ array(
+ PhortuneAccountHasMemberEdgeType::EDGECONST,
+ ));
$member_phids = array_reverse($member_phids);
$account->attachMemberPHIDs($member_phids);
+
+ $merchant_phids = $query->getDestinationPHIDs(
+ array(
+ $account->getPHID(),
+ ),
+ array(
+ PhortuneAccountHasMerchantEdgeType::EDGECONST,
+ ));
+ $merchant_phids = array_reverse($merchant_phids);
+ $account->attachMerchantPHIDs($merchant_phids);
}
return $accounts;
diff --git a/src/applications/phortune/storage/PhortuneAccount.php b/src/applications/phortune/storage/PhortuneAccount.php
--- a/src/applications/phortune/storage/PhortuneAccount.php
+++ b/src/applications/phortune/storage/PhortuneAccount.php
@@ -16,11 +16,13 @@
protected $billingAddress;
private $memberPHIDs = self::ATTACHABLE;
+ private $merchantPHIDs = self::ATTACHABLE;
public static function initializeNewAccount(PhabricatorUser $actor) {
return id(new self())
->setBillingName('')
->setBillingAddress('')
+ ->attachMerchantPHIDs(array())
->attachMemberPHIDs(array());
}
@@ -115,6 +117,26 @@
$this->getID());
}
+ public function attachMerchantPHIDs(array $merchant_phids) {
+ $this->merchantPHIDs = $merchant_phids;
+ return $this;
+ }
+
+ public function getMerchantPHIDs() {
+ return $this->assertAttached($this->merchantPHIDs);
+ }
+
+ public function writeMerchantEdge(PhortuneMerchant $merchant) {
+ $edge_src = $this->getPHID();
+ $edge_type = PhortuneAccountHasMerchantEdgeType::EDGECONST;
+ $edge_dst = $merchant->getPHID();
+
+ id(new PhabricatorEdgeEditor())
+ ->addEdge($edge_src, $edge_type, $edge_dst)
+ ->save();
+
+ return $this;
+ }
/* -( PhabricatorApplicationTransactionInterface )------------------------- */
diff --git a/src/applications/phortune/storage/PhortuneSubscription.php b/src/applications/phortune/storage/PhortuneSubscription.php
--- a/src/applications/phortune/storage/PhortuneSubscription.php
+++ b/src/applications/phortune/storage/PhortuneSubscription.php
@@ -161,6 +161,10 @@
}
$this->saveTransaction();
+ $account = $this->getAccount();
+ $merchant = $this->getMerchant();
+ $account->writeMerchantEdge($merchant);
+
return $result;
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Jan 12, 1:28 AM (20 h, 49 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6985533
Default Alt Text
D20715.id49432.diff (10 KB)
Attached To
Mode
D20715: In Phortune, write relationships between payment accounts and merchants they interact with
Attached
Detach File
Event Timeline
Log In to Comment