Differential D20220 Diff 48333 src/applications/harbormaster/editor/HarbormasterBuildPlanEditEngine.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/harbormaster/editor/HarbormasterBuildPlanEditEngine.php
| Show First 20 Lines • Show All 71 Lines • ▼ Show 20 Lines | final class HarbormasterBuildPlanEditEngine | ||||
| } | } | ||||
| protected function getCreateNewObjectPolicy() { | protected function getCreateNewObjectPolicy() { | ||||
| return $this->getApplication()->getPolicy( | return $this->getApplication()->getPolicy( | ||||
| HarbormasterCreatePlansCapability::CAPABILITY); | HarbormasterCreatePlansCapability::CAPABILITY); | ||||
| } | } | ||||
| protected function buildCustomEditFields($object) { | protected function buildCustomEditFields($object) { | ||||
| return array( | $fields = array( | ||||
| id(new PhabricatorTextEditField()) | id(new PhabricatorTextEditField()) | ||||
| ->setKey('name') | ->setKey('name') | ||||
| ->setLabel(pht('Name')) | ->setLabel(pht('Name')) | ||||
| ->setIsRequired(true) | ->setIsRequired(true) | ||||
| ->setTransactionType( | ->setTransactionType( | ||||
| HarbormasterBuildPlanNameTransaction::TRANSACTIONTYPE) | HarbormasterBuildPlanNameTransaction::TRANSACTIONTYPE) | ||||
| ->setDescription(pht('The build plan name.')) | ->setDescription(pht('The build plan name.')) | ||||
| ->setConduitDescription(pht('Rename the plan.')) | ->setConduitDescription(pht('Rename the plan.')) | ||||
| ->setConduitTypeDescription(pht('New plan name.')) | ->setConduitTypeDescription(pht('New plan name.')) | ||||
| ->setValue($object->getName()), | ->setValue($object->getName()), | ||||
| ); | ); | ||||
| $metadata_key = HarbormasterBuildPlanBehavior::getTransactionMetadataKey(); | |||||
| $behaviors = HarbormasterBuildPlanBehavior::newPlanBehaviors(); | |||||
| foreach ($behaviors as $behavior) { | |||||
| $key = $behavior->getKey(); | |||||
| // Get the raw key off the object so that we don't reset stuff to | |||||
| // default values by mistake if a behavior goes missing somehow. | |||||
| $storage_key = HarbormasterBuildPlanBehavior::getStorageKeyForBehaviorKey( | |||||
| $key); | |||||
| $behavior_option = $object->getPlanProperty($storage_key); | |||||
| if (!strlen($behavior_option)) { | |||||
| $behavior_option = $behavior->getPlanOption($object)->getKey(); | |||||
| } | |||||
| $fields[] = id(new PhabricatorSelectEditField()) | |||||
| ->setIsFormField(false) | |||||
| ->setKey(sprintf('behavior.%s', $behavior->getKey())) | |||||
| ->setMetadataValue($metadata_key, $behavior->getKey()) | |||||
| ->setLabel(pht('Behavior: %s', $behavior->getName())) | |||||
| ->setTransactionType( | |||||
| HarbormasterBuildPlanBehaviorTransaction::TRANSACTIONTYPE) | |||||
| ->setValue($behavior_option) | |||||
| ->setOptions($behavior->getOptionMap()); | |||||
| } | |||||
| return $fields; | |||||
| } | } | ||||
| } | } | ||||