Differential D14896 Diff 36004 src/infrastructure/customfield/standard/PhabricatorStandardCustomField.php
Changeset View
Changeset View
Standalone View
Standalone View
src/infrastructure/customfield/standard/PhabricatorStandardCustomField.php
| Show All 11 Lines | abstract class PhabricatorStandardCustomField | ||||
| private $applicationField; | private $applicationField; | ||||
| private $strings = array(); | private $strings = array(); | ||||
| private $caption; | private $caption; | ||||
| private $fieldError; | private $fieldError; | ||||
| private $required; | private $required; | ||||
| private $default; | private $default; | ||||
| private $isCopyable; | private $isCopyable; | ||||
| private $hasStorageValue; | private $hasStorageValue; | ||||
| private $isBuiltin; | |||||
| abstract public function getFieldType(); | abstract public function getFieldType(); | ||||
| public static function buildStandardFields( | public static function buildStandardFields( | ||||
| PhabricatorCustomField $template, | PhabricatorCustomField $template, | ||||
| array $config) { | array $config, | ||||
| $builtin = false) { | |||||
| $types = id(new PhutilClassMapQuery()) | $types = id(new PhutilClassMapQuery()) | ||||
| ->setAncestorClass(__CLASS__) | ->setAncestorClass(__CLASS__) | ||||
| ->setUniqueMethod('getFieldType') | ->setUniqueMethod('getFieldType') | ||||
| ->execute(); | ->execute(); | ||||
| $fields = array(); | $fields = array(); | ||||
| foreach ($config as $key => $value) { | foreach ($config as $key => $value) { | ||||
| Show All 9 Lines | foreach ($config as $key => $value) { | ||||
| $template = clone $template; | $template = clone $template; | ||||
| $standard = id(clone $types[$type]) | $standard = id(clone $types[$type]) | ||||
| ->setRawStandardFieldKey($key) | ->setRawStandardFieldKey($key) | ||||
| ->setFieldKey($full_key) | ->setFieldKey($full_key) | ||||
| ->setFieldConfig($value) | ->setFieldConfig($value) | ||||
| ->setApplicationField($template); | ->setApplicationField($template); | ||||
| if ($builtin) { | |||||
| $standard->setIsBuiltin(true); | |||||
| } | |||||
| $field = $template->setProxy($standard); | $field = $template->setProxy($standard); | ||||
| $fields[] = $field; | $fields[] = $field; | ||||
| } | } | ||||
| return $fields; | return $fields; | ||||
| } | } | ||||
| public function setApplicationField( | public function setApplicationField( | ||||
| Show All 29 Lines | public function getCaption() { | ||||
| return $this->caption; | return $this->caption; | ||||
| } | } | ||||
| public function setFieldDescription($description) { | public function setFieldDescription($description) { | ||||
| $this->fieldDescription = $description; | $this->fieldDescription = $description; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function setIsBuiltin($is_builtin) { | |||||
| $this->isBuiltin = $is_builtin; | |||||
| return $this; | |||||
| } | |||||
| public function getIsBuiltin() { | |||||
| return $this->isBuiltin; | |||||
| } | |||||
| public function setFieldConfig(array $config) { | public function setFieldConfig(array $config) { | ||||
| foreach ($config as $key => $value) { | foreach ($config as $key => $value) { | ||||
| switch ($key) { | switch ($key) { | ||||
| case 'name': | case 'name': | ||||
| $this->setFieldName($value); | $this->setFieldName($value); | ||||
| break; | break; | ||||
| case 'description': | case 'description': | ||||
| $this->setFieldDescription($value); | $this->setFieldDescription($value); | ||||
| ▲ Show 20 Lines • Show All 361 Lines • ▼ Show 20 Lines | public function shouldAppearInConduitTransactions() { | ||||
| return true; | return true; | ||||
| } | } | ||||
| public function shouldAppearInConduitDictionary() { | public function shouldAppearInConduitDictionary() { | ||||
| return true; | return true; | ||||
| } | } | ||||
| public function getModernFieldKey() { | public function getModernFieldKey() { | ||||
| if ($this->getIsBuiltin()) { | |||||
| return $this->getRawStandardFieldKey(); | |||||
| } else { | |||||
| return 'custom.'.$this->getRawStandardFieldKey(); | return 'custom.'.$this->getRawStandardFieldKey(); | ||||
| } | } | ||||
| } | |||||
| public function getConduitDictionaryValue() { | public function getConduitDictionaryValue() { | ||||
| return $this->getFieldValue(); | return $this->getFieldValue(); | ||||
| } | } | ||||
| } | } | ||||