Path: blob/master/src/applications/fund/editor/FundInitiativeEditEngine.php
12256 views
<?php12final class FundInitiativeEditEngine3extends PhabricatorEditEngine {45const ENGINECONST = 'fund.initiative';67public function getEngineName() {8return pht('Fund');9}1011public function getEngineApplicationClass() {12return 'PhabricatorFundApplication';13}1415public function getSummaryHeader() {16return pht('Configure Fund Forms');17}1819public function getSummaryText() {20return pht('Configure creation and editing forms in Fund.');21}2223public function isEngineConfigurable() {24return false;25}2627protected function newEditableObject() {28return FundInitiative::initializeNewInitiative($this->getViewer());29}3031protected function newObjectQuery() {32return new FundInitiativeQuery();33}3435protected function getObjectCreateTitleText($object) {36return pht('Create New Initiative');37}3839protected function getObjectEditTitleText($object) {40return pht('Edit Initiative: %s', $object->getName());41}4243protected function getObjectEditShortText($object) {44return $object->getName();45}4647protected function getObjectCreateShortText() {48return pht('Create Initiative');49}5051protected function getObjectName() {52return pht('Initiative');53}5455protected function getObjectCreateCancelURI($object) {56return $this->getApplication()->getApplicationURI('/');57}5859protected function getEditorURI() {60return $this->getApplication()->getApplicationURI('edit/');61}6263protected function getObjectViewURI($object) {64return $object->getViewURI();65}6667protected function getCreateNewObjectPolicy() {68return $this->getApplication()->getPolicy(69FundCreateInitiativesCapability::CAPABILITY);70}7172protected function buildCustomEditFields($object) {73$viewer = $this->getViewer();74$v_merchant = $object->getMerchantPHID();7576$merchants = id(new PhortuneMerchantQuery())77->setViewer($viewer)78->requireCapabilities(79array(80PhabricatorPolicyCapability::CAN_VIEW,81PhabricatorPolicyCapability::CAN_EDIT,82))83->execute();8485$merchant_options = array();86foreach ($merchants as $merchant) {87$merchant_options[$merchant->getPHID()] = pht(88'Merchant %d %s',89$merchant->getID(),90$merchant->getName());91}9293if ($v_merchant && empty($merchant_options[$v_merchant])) {94$merchant_options = array(95$v_merchant => pht('(Restricted Merchant)'),96) + $merchant_options;97}9899$merchant_instructions = null;100if (!$merchant_options) {101$merchant_instructions = pht(102'NOTE: You do not control any merchant accounts which can receive '.103'payments from this initiative. When you create an initiative, '.104'you need to specify a merchant account where funds will be paid '.105'to. Create a merchant account in the Phortune application before '.106'creating an initiative in Fund.');107}108109return array(110id(new PhabricatorTextEditField())111->setKey('name')112->setLabel(pht('Name'))113->setDescription(pht('Initiative name.'))114->setConduitTypeDescription(pht('New initiative name.'))115->setTransactionType(116FundInitiativeNameTransaction::TRANSACTIONTYPE)117->setValue($object->getName())118->setIsRequired(true),119id(new PhabricatorSelectEditField())120->setKey('merchantPHID')121->setLabel(pht('Merchant'))122->setDescription(pht('Merchant operating the initiative.'))123->setConduitTypeDescription(pht('New initiative merchant.'))124->setControlInstructions($merchant_instructions)125->setValue($object->getMerchantPHID())126->setTransactionType(127FundInitiativeMerchantTransaction::TRANSACTIONTYPE)128->setOptions($merchant_options)129->setIsRequired(true),130id(new PhabricatorRemarkupEditField())131->setKey('description')132->setLabel(pht('Description'))133->setDescription(pht('Initiative long description.'))134->setConduitTypeDescription(pht('New initiative description.'))135->setTransactionType(136FundInitiativeDescriptionTransaction::TRANSACTIONTYPE)137->setValue($object->getDescription()),138id(new PhabricatorRemarkupEditField())139->setKey('risks')140->setLabel(pht('Risks/Challenges'))141->setDescription(pht('Initiative risks and challenges.'))142->setConduitTypeDescription(pht('Initiative risks and challenges.'))143->setTransactionType(144FundInitiativeRisksTransaction::TRANSACTIONTYPE)145->setValue($object->getRisks()),146147);148149}150151}152153154