Differential D18159 Diff 43687 src/applications/config/option/PhabricatorApplicationConfigOptions.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/config/option/PhabricatorApplicationConfigOptions.php
Show All 37 Lines | if ($option->isCustomType()) { | ||||
try { | try { | ||||
return $option->getCustomObject()->validateOption($option, $value); | return $option->getCustomObject()->validateOption($option, $value); | ||||
} catch (Exception $ex) { | } catch (Exception $ex) { | ||||
throw new PhabricatorConfigValidationException($ex->getMessage()); | throw new PhabricatorConfigValidationException($ex->getMessage()); | ||||
} | } | ||||
} | } | ||||
switch ($option->getType()) { | switch ($option->getType()) { | ||||
case 'class': | |||||
$symbols = id(new PhutilSymbolLoader()) | |||||
->setType('class') | |||||
->setAncestorClass($option->getBaseClass()) | |||||
->setConcreteOnly(true) | |||||
->selectSymbolsWithoutLoading(); | |||||
$names = ipull($symbols, 'name', 'name'); | |||||
if (empty($names[$value])) { | |||||
throw new PhabricatorConfigValidationException( | |||||
pht( | |||||
"Option '%s' value must name a class extending '%s'.", | |||||
$option->getKey(), | |||||
$option->getBaseClass())); | |||||
} | |||||
break; | |||||
case 'set': | case 'set': | ||||
$valid = true; | $valid = true; | ||||
if (!is_array($value)) { | if (!is_array($value)) { | ||||
throw new PhabricatorConfigValidationException( | throw new PhabricatorConfigValidationException( | ||||
pht( | pht( | ||||
"Option '%s' must be a set, but value is not an array.", | "Option '%s' must be a set, but value is not an array.", | ||||
$option->getKey())); | $option->getKey())); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 120 Lines • Show Last 20 Lines |