Path: blob/master/src/applications/harbormaster/editor/HarbormasterBuildPlanEditEngine.php
12256 views
<?php12final class HarbormasterBuildPlanEditEngine3extends PhabricatorEditEngine {45const ENGINECONST = 'harbormaster.buildplan';67public function isEngineConfigurable() {8return false;9}1011public function getEngineName() {12return pht('Harbormaster Build Plans');13}1415public function getSummaryHeader() {16return pht('Edit Harbormaster Build Plan Configurations');17}1819public function getSummaryText() {20return pht('This engine is used to edit Harbormaster build plans.');21}2223public function getEngineApplicationClass() {24return 'PhabricatorHarbormasterApplication';25}2627protected function newEditableObject() {28$viewer = $this->getViewer();29return HarbormasterBuildPlan::initializeNewBuildPlan($viewer);30}3132protected function newObjectQuery() {33return new HarbormasterBuildPlanQuery();34}3536protected function getObjectCreateTitleText($object) {37return pht('Create Build Plan');38}3940protected function getObjectCreateButtonText($object) {41return pht('Create Build Plan');42}4344protected function getObjectEditTitleText($object) {45return pht('Edit Build Plan: %s', $object->getName());46}4748protected function getObjectEditShortText($object) {49return pht('Edit Build Plan');50}5152protected function getObjectCreateShortText() {53return pht('Create Build Plan');54}5556protected function getObjectName() {57return pht('Build Plan');58}5960protected function getEditorURI() {61return '/harbormaster/plan/edit/';62}6364protected function getObjectCreateCancelURI($object) {65return '/harbormaster/plan/';66}6768protected function getObjectViewURI($object) {69$id = $object->getID();70return "/harbormaster/plan/{$id}/";71}7273protected function getCreateNewObjectPolicy() {74return $this->getApplication()->getPolicy(75HarbormasterCreatePlansCapability::CAPABILITY);76}7778protected function buildCustomEditFields($object) {79$fields = array(80id(new PhabricatorTextEditField())81->setKey('name')82->setLabel(pht('Name'))83->setIsRequired(true)84->setTransactionType(85HarbormasterBuildPlanNameTransaction::TRANSACTIONTYPE)86->setDescription(pht('The build plan name.'))87->setConduitDescription(pht('Rename the plan.'))88->setConduitTypeDescription(pht('New plan name.'))89->setValue($object->getName()),90);919293$metadata_key = HarbormasterBuildPlanBehavior::getTransactionMetadataKey();9495$behaviors = HarbormasterBuildPlanBehavior::newPlanBehaviors();96foreach ($behaviors as $behavior) {97$key = $behavior->getKey();9899// Get the raw key off the object so that we don't reset stuff to100// default values by mistake if a behavior goes missing somehow.101$storage_key = HarbormasterBuildPlanBehavior::getStorageKeyForBehaviorKey(102$key);103$behavior_option = $object->getPlanProperty($storage_key);104105if ($behavior_option === null || !strlen($behavior_option)) {106$behavior_option = $behavior->getPlanOption($object)->getKey();107}108109$fields[] = id(new PhabricatorSelectEditField())110->setIsFormField(false)111->setKey(sprintf('behavior.%s', $behavior->getKey()))112->setMetadataValue($metadata_key, $behavior->getKey())113->setLabel(pht('Behavior: %s', $behavior->getName()))114->setTransactionType(115HarbormasterBuildPlanBehaviorTransaction::TRANSACTIONTYPE)116->setValue($behavior_option)117->setOptions($behavior->getOptionMap());118}119120return $fields;121}122123}124125126