3 final class FundInitiativeEditEngine
4 extends PhabricatorEditEngine
{
6 const ENGINECONST
= 'fund.initiative';
8 public function getEngineName() {
12 public function getEngineApplicationClass() {
13 return 'PhabricatorFundApplication';
16 public function getSummaryHeader() {
17 return pht('Configure Fund Forms');
20 public function getSummaryText() {
21 return pht('Configure creation and editing forms in Fund.');
24 public function isEngineConfigurable() {
28 protected function newEditableObject() {
29 return FundInitiative
::initializeNewInitiative($this->getViewer());
32 protected function newObjectQuery() {
33 return new FundInitiativeQuery();
36 protected function getObjectCreateTitleText($object) {
37 return pht('Create New Initiative');
40 protected function getObjectEditTitleText($object) {
41 return pht('Edit Initiative: %s', $object->getName());
44 protected function getObjectEditShortText($object) {
45 return $object->getName();
48 protected function getObjectCreateShortText() {
49 return pht('Create Initiative');
52 protected function getObjectName() {
53 return pht('Initiative');
56 protected function getObjectCreateCancelURI($object) {
57 return $this->getApplication()->getApplicationURI('/');
60 protected function getEditorURI() {
61 return $this->getApplication()->getApplicationURI('edit/');
64 protected function getObjectViewURI($object) {
65 return $object->getViewURI();
68 protected function getCreateNewObjectPolicy() {
69 return $this->getApplication()->getPolicy(
70 FundCreateInitiativesCapability
::CAPABILITY
);
73 protected function buildCustomEditFields($object) {
74 $viewer = $this->getViewer();
75 $v_merchant = $object->getMerchantPHID();
77 $merchants = id(new PhortuneMerchantQuery())
79 ->requireCapabilities(
81 PhabricatorPolicyCapability
::CAN_VIEW
,
82 PhabricatorPolicyCapability
::CAN_EDIT
,
86 $merchant_options = array();
87 foreach ($merchants as $merchant) {
88 $merchant_options[$merchant->getPHID()] = pht(
91 $merchant->getName());
94 if ($v_merchant && empty($merchant_options[$v_merchant])) {
95 $merchant_options = array(
96 $v_merchant => pht('(Restricted Merchant)'),
97 ) +
$merchant_options;
100 $merchant_instructions = null;
101 if (!$merchant_options) {
102 $merchant_instructions = pht(
103 'NOTE: You do not control any merchant accounts which can receive '.
104 'payments from this initiative. When you create an initiative, '.
105 'you need to specify a merchant account where funds will be paid '.
106 'to. Create a merchant account in the Phortune application before '.
107 'creating an initiative in Fund.');
111 id(new PhabricatorTextEditField())
113 ->setLabel(pht('Name'))
114 ->setDescription(pht('Initiative name.'))
115 ->setConduitTypeDescription(pht('New initiative name.'))
116 ->setTransactionType(
117 FundInitiativeNameTransaction
::TRANSACTIONTYPE
)
118 ->setValue($object->getName())
119 ->setIsRequired(true),
120 id(new PhabricatorSelectEditField())
121 ->setKey('merchantPHID')
122 ->setLabel(pht('Merchant'))
123 ->setDescription(pht('Merchant operating the initiative.'))
124 ->setConduitTypeDescription(pht('New initiative merchant.'))
125 ->setControlInstructions($merchant_instructions)
126 ->setValue($object->getMerchantPHID())
127 ->setTransactionType(
128 FundInitiativeMerchantTransaction
::TRANSACTIONTYPE
)
129 ->setOptions($merchant_options)
130 ->setIsRequired(true),
131 id(new PhabricatorRemarkupEditField())
132 ->setKey('description')
133 ->setLabel(pht('Description'))
134 ->setDescription(pht('Initiative long description.'))
135 ->setConduitTypeDescription(pht('New initiative description.'))
136 ->setTransactionType(
137 FundInitiativeDescriptionTransaction
::TRANSACTIONTYPE
)
138 ->setValue($object->getDescription()),
139 id(new PhabricatorRemarkupEditField())
141 ->setLabel(pht('Risks/Challenges'))
142 ->setDescription(pht('Initiative risks and challenges.'))
143 ->setConduitTypeDescription(pht('Initiative risks and challenges.'))
144 ->setTransactionType(
145 FundInitiativeRisksTransaction
::TRANSACTIONTYPE
)
146 ->setValue($object->getRisks()),