Differential D18159 Diff 43687 src/applications/config/controller/PhabricatorConfigEditController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/config/controller/PhabricatorConfigEditController.php
Show First 20 Lines • Show All 344 Lines • ▼ Show 20 Lines | if ($option->isCustomType()) { | ||||
$type = $option->getType(); | $type = $option->getType(); | ||||
$set_value = null; | $set_value = null; | ||||
switch ($type) { | switch ($type) { | ||||
case 'set': | case 'set': | ||||
$set_value = array_fill_keys($request->getStrList('value'), true); | $set_value = array_fill_keys($request->getStrList('value'), true); | ||||
break; | break; | ||||
case 'class': | |||||
if (!class_exists($value)) { | |||||
$e_value = pht('Invalid'); | |||||
$errors[] = pht('Class does not exist.'); | |||||
} else { | |||||
$base = $option->getBaseClass(); | |||||
if (!is_subclass_of($value, $base)) { | |||||
$e_value = pht('Invalid'); | |||||
$errors[] = pht('Class is not of valid type.'); | |||||
} else { | |||||
$set_value = $value; | |||||
} | |||||
} | |||||
break; | |||||
default: | default: | ||||
$json = json_decode($value, true); | $json = json_decode($value, true); | ||||
if ($json === null && strtolower($value) != 'null') { | if ($json === null && strtolower($value) != 'null') { | ||||
$e_value = pht('Invalid'); | $e_value = pht('Invalid'); | ||||
$errors[] = pht( | $errors[] = pht( | ||||
'The given value must be valid JSON. This means, among '. | 'The given value must be valid JSON. This means, among '. | ||||
'other things, that you must wrap strings in double-quotes.'); | 'other things, that you must wrap strings in double-quotes.'); | ||||
} else { | } else { | ||||
Show All 29 Lines | private function getDisplayValue( | ||||
if ($option->isCustomType()) { | if ($option->isCustomType()) { | ||||
return $option->getCustomObject()->getDisplayValue( | return $option->getCustomObject()->getDisplayValue( | ||||
$option, | $option, | ||||
$entry, | $entry, | ||||
$value); | $value); | ||||
} else { | } else { | ||||
$type = $option->getType(); | $type = $option->getType(); | ||||
switch ($type) { | switch ($type) { | ||||
case 'class': | |||||
return $value; | |||||
case 'set': | case 'set': | ||||
return implode("\n", nonempty(array_keys($value), array())); | return implode("\n", nonempty(array_keys($value), array())); | ||||
default: | default: | ||||
return PhabricatorConfigJSON::prettyPrintJSON($value); | return PhabricatorConfigJSON::prettyPrintJSON($value); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
Show All 13 Lines | private function renderControls( | ||||
if ($option->isCustomType()) { | if ($option->isCustomType()) { | ||||
$controls = $option->getCustomObject()->renderControls( | $controls = $option->getCustomObject()->renderControls( | ||||
$option, | $option, | ||||
$display_value, | $display_value, | ||||
$e_value); | $e_value); | ||||
} else { | } else { | ||||
$type = $option->getType(); | $type = $option->getType(); | ||||
switch ($type) { | switch ($type) { | ||||
case 'class': | |||||
$symbols = id(new PhutilSymbolLoader()) | |||||
->setType('class') | |||||
->setAncestorClass($option->getBaseClass()) | |||||
->setConcreteOnly(true) | |||||
->selectSymbolsWithoutLoading(); | |||||
$names = ipull($symbols, 'name', 'name'); | |||||
asort($names); | |||||
$names = array( | |||||
'' => pht('(Use Default)'), | |||||
) + $names; | |||||
$control = id(new AphrontFormSelectControl()) | |||||
->setOptions($names); | |||||
break; | |||||
case 'set': | case 'set': | ||||
$control = id(new AphrontFormTextAreaControl()) | $control = id(new AphrontFormTextAreaControl()) | ||||
->setCaption(pht('Separate values with newlines or commas.')); | ->setCaption(pht('Separate values with newlines or commas.')); | ||||
break; | break; | ||||
default: | default: | ||||
$control = id(new AphrontFormTextAreaControl()) | $control = id(new AphrontFormTextAreaControl()) | ||||
->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL) | ->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL) | ||||
->setCustomClass('PhabricatorMonospaced') | ->setCustomClass('PhabricatorMonospaced') | ||||
▲ Show 20 Lines • Show All 114 Lines • Show Last 20 Lines |