diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -3692,6 +3692,7 @@ 'PhabricatorOlderInlinesSetting' => 'applications/settings/setting/PhabricatorOlderInlinesSetting.php', 'PhabricatorOneTimeTriggerClock' => 'infrastructure/daemon/workers/clock/PhabricatorOneTimeTriggerClock.php', 'PhabricatorOpcodeCacheSpec' => 'applications/cache/spec/PhabricatorOpcodeCacheSpec.php', + 'PhabricatorOptionExportField' => 'infrastructure/export/field/PhabricatorOptionExportField.php', 'PhabricatorOptionGroupSetting' => 'applications/settings/setting/PhabricatorOptionGroupSetting.php', 'PhabricatorOwnerPathQuery' => 'applications/owners/query/PhabricatorOwnerPathQuery.php', 'PhabricatorOwnersApplication' => 'applications/owners/application/PhabricatorOwnersApplication.php', @@ -9687,6 +9688,7 @@ 'PhabricatorOlderInlinesSetting' => 'PhabricatorSelectSetting', 'PhabricatorOneTimeTriggerClock' => 'PhabricatorTriggerClock', 'PhabricatorOpcodeCacheSpec' => 'PhabricatorCacheSpec', + 'PhabricatorOptionExportField' => 'PhabricatorExportField', 'PhabricatorOptionGroupSetting' => 'PhabricatorSetting', 'PhabricatorOwnerPathQuery' => 'Phobject', 'PhabricatorOwnersApplication' => 'PhabricatorApplication', diff --git a/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldSelect.php b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldSelect.php --- a/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldSelect.php +++ b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldSelect.php @@ -153,4 +153,9 @@ ->setOptions($this->getOptions()); } + protected function newExportFieldType() { + return id(new PhabricatorOptionExportField()) + ->setOptions($this->getOptions()); + } + } diff --git a/src/infrastructure/export/field/PhabricatorOptionExportField.php b/src/infrastructure/export/field/PhabricatorOptionExportField.php new file mode 100644 --- /dev/null +++ b/src/infrastructure/export/field/PhabricatorOptionExportField.php @@ -0,0 +1,47 @@ +options = $options; + return $this; + } + + public function getOptions() { + return $this->options; + } + + public function getNaturalValue($value) { + if ($value === null) { + return $value; + } + + if (!strlen($value)) { + return null; + } + + $options = $this->getOptions(); + + return array( + 'value' => (string)$value, + 'name' => (string)idx($options, $value, $value), + ); + } + + public function getTextValue($value) { + $natural_value = $this->getNaturalValue($value); + if ($natural_value === null) { + return null; + } + + return $natural_value['name']; + } + + public function getPHPExcelValue($value) { + return $this->getTextValue($value); + } + +}