@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.)
hq.recaptime.dev/wiki/Phorge
phorge
phabricator
1<?php
2
3final class PhortuneAccountEditEngine
4 extends PhabricatorEditEngine {
5
6 const ENGINECONST = 'phortune.account';
7
8 public function getEngineName() {
9 return pht('Phortune Accounts');
10 }
11
12 public function getEngineApplicationClass() {
13 return PhabricatorPhortuneApplication::class;
14 }
15
16 public function getSummaryHeader() {
17 return pht('Configure Phortune Account Forms');
18 }
19
20 public function getSummaryText() {
21 return pht('Configure creation and editing forms in Phortune Accounts.');
22 }
23
24 public function isEngineConfigurable() {
25 return false;
26 }
27
28 protected function newEditableObject() {
29 return PhortuneAccount::initializeNewAccount($this->getViewer());
30 }
31
32 protected function newObjectQuery() {
33 return new PhortuneAccountQuery();
34 }
35
36 protected function getObjectCreateTitleText($object) {
37 return pht('Create Payment Account');
38 }
39
40 protected function getObjectEditTitleText($object) {
41 return pht('Edit Account: %s', $object->getName());
42 }
43
44 protected function getObjectEditShortText($object) {
45 return $object->getName();
46 }
47
48 protected function getObjectCreateShortText() {
49 return pht('Create Account');
50 }
51
52 protected function getObjectName() {
53 return pht('Account');
54 }
55
56 protected function getObjectCreateCancelURI($object) {
57 return $this->getApplication()->getApplicationURI('/');
58 }
59
60 protected function getEditorURI() {
61 return $this->getApplication()->getApplicationURI('edit/');
62 }
63
64 protected function getObjectViewURI($object) {
65 if ($this->getIsCreate()) {
66 return $object->getURI();
67 } else {
68 return $object->getDetailsURI();
69 }
70 }
71
72 protected function buildCustomEditFields($object) {
73 $viewer = $this->getViewer();
74
75 if ($this->getIsCreate()) {
76 $member_phids = array($viewer->getPHID());
77 } else {
78 $member_phids = $object->getMemberPHIDs();
79 }
80
81 $fields = array(
82 id(new PhabricatorTextEditField())
83 ->setKey('name')
84 ->setLabel(pht('Name'))
85 ->setDescription(pht('Account name.'))
86 ->setConduitTypeDescription(pht('New account name.'))
87 ->setTransactionType(
88 PhortuneAccountNameTransaction::TRANSACTIONTYPE)
89 ->setValue($object->getName())
90 ->setIsRequired(true),
91
92 id(new PhabricatorUsersEditField())
93 ->setKey('managers')
94 ->setAliases(array('memberPHIDs', 'managerPHIDs'))
95 ->setLabel(pht('Managers'))
96 ->setUseEdgeTransactions(true)
97 ->setTransactionType(PhabricatorTransactions::TYPE_EDGE)
98 ->setMetadataValue(
99 'edge:type',
100 PhortuneAccountHasMemberEdgeType::EDGECONST)
101 ->setDescription(pht('Initial account managers.'))
102 ->setConduitDescription(pht('Set account managers.'))
103 ->setConduitTypeDescription(pht('New list of managers.'))
104 ->setInitialValue($object->getMemberPHIDs())
105 ->setValue($member_phids),
106
107 id(new PhabricatorTextEditField())
108 ->setKey('billingName')
109 ->setLabel(pht('Billing Name'))
110 ->setDescription(pht('Account name for billing purposes.'))
111 ->setConduitTypeDescription(pht('New account billing name.'))
112 ->setTransactionType(
113 PhortuneAccountBillingNameTransaction::TRANSACTIONTYPE)
114 ->setValue($object->getBillingName()),
115
116 id(new PhabricatorTextAreaEditField())
117 ->setKey('billingAddress')
118 ->setLabel(pht('Billing Address'))
119 ->setDescription(pht('Account billing address.'))
120 ->setConduitTypeDescription(pht('New account billing address.'))
121 ->setTransactionType(
122 PhortuneAccountBillingAddressTransaction::TRANSACTIONTYPE)
123 ->setValue($object->getBillingAddress()),
124
125 );
126
127 return $fields;
128
129 }
130
131}