@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 PhortuneAccountEmailEditEngine
4 extends PhabricatorEditEngine {
5
6 const ENGINECONST = 'phortune.account.email';
7
8 private $account;
9
10 public function setAccount(PhortuneAccount $account) {
11 $this->account = $account;
12 return $this;
13 }
14
15 public function getAccount() {
16 return $this->account;
17 }
18
19 public function getEngineName() {
20 return pht('Phortune Account Emails');
21 }
22
23 public function getEngineApplicationClass() {
24 return PhabricatorPhortuneApplication::class;
25 }
26
27 public function getSummaryHeader() {
28 return pht('Configure Phortune Account Email Forms');
29 }
30
31 public function getSummaryText() {
32 return pht(
33 'Configure creation and editing forms for Phortune Account '.
34 'Email Addresses.');
35 }
36
37 public function isEngineConfigurable() {
38 return false;
39 }
40
41 protected function newEditableObject() {
42 $viewer = $this->getViewer();
43
44 $account = $this->getAccount();
45 if (!$account) {
46 $account = new PhortuneAccount();
47 }
48
49 return PhortuneAccountEmail::initializeNewAddress(
50 $account,
51 $viewer->getPHID());
52 }
53
54 protected function newObjectQuery() {
55 return new PhortuneAccountEmailQuery();
56 }
57
58 protected function getObjectCreateTitleText($object) {
59 return pht('Add Email Address');
60 }
61
62 protected function getObjectEditTitleText($object) {
63 return pht('Edit Account Email: %s', $object->getAddress());
64 }
65
66 protected function getObjectEditShortText($object) {
67 return pht('%s', $object->getAddress());
68 }
69
70 protected function getObjectCreateShortText() {
71 return pht('Add Email Address');
72 }
73
74 protected function getObjectName() {
75 return pht('Account Email');
76 }
77
78 protected function getObjectCreateCancelURI($object) {
79 return $this->getAccount()->getEmailAddressesURI();
80 }
81
82 protected function getEditorURI() {
83 return $this->getApplication()->getApplicationURI('address/edit/');
84 }
85
86 protected function getObjectViewURI($object) {
87 return $object->getURI();
88 }
89
90 protected function buildCustomEditFields($object) {
91 $viewer = $this->getViewer();
92
93 if ($this->getIsCreate()) {
94 $address_field = id(new PhabricatorTextEditField())
95 ->setTransactionType(
96 PhortuneAccountEmailAddressTransaction::TRANSACTIONTYPE)
97 ->setIsRequired(true);
98 } else {
99 $address_field = new PhabricatorStaticEditField();
100 }
101
102 $address_field
103 ->setKey('address')
104 ->setLabel(pht('Email Address'))
105 ->setDescription(pht('Email address.'))
106 ->setConduitTypeDescription(pht('New email address.'))
107 ->setValue($object->getAddress());
108
109 return array(
110 $address_field,
111 );
112 }
113
114}