public static function buildStandardFields(PhabricatorCustomField $template, array $config) { $types = id(new PhutilClassMapQuery())->setAncestorClass(__CLASS__)->setUniqueMethod('getFieldType')->execute(); $fields = array(); foreach ($config as $key => $value) { $type = idx($value, 'type', 'text'); if (empty($types[$type])) { // TODO: We should have better typechecking somewhere, and then make // this more serious. continue; } $namespace = $template->getStandardCustomFieldNamespace(); $full_key = "std:{$namespace}:{$key}"; $template = clone $template; $standard = id(clone $types[$type])->setRawStandardFieldKey($key)->setFieldKey($full_key)->setFieldConfig($value)->setApplicationField($template); $field = $template->setProxy($standard); $fields[] = $field; } return $fields; }