Differential D12806 Diff 30846 src/applications/config/option/PhabricatorApplicationConfigOptions.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/config/option/PhabricatorApplicationConfigOptions.php
| Show First 20 Lines • Show All 181 Lines • ▼ Show 20 Lines | return id(new PhabricatorConfigOption()) | ||||
| ->setKey($key) | ->setKey($key) | ||||
| ->setType($type) | ->setType($type) | ||||
| ->setDefault($default) | ->setDefault($default) | ||||
| ->setGroup($this); | ->setGroup($this); | ||||
| } | } | ||||
| final public static function loadAll($external_only = false) { | final public static function loadAll($external_only = false) { | ||||
| $symbols = id(new PhutilSymbolLoader()) | $symbols = id(new PhutilSymbolLoader()) | ||||
| ->setAncestorClass('PhabricatorApplicationConfigOptions') | ->setAncestorClass(__CLASS__) | ||||
| ->setConcreteOnly(true) | ->setConcreteOnly(true) | ||||
| ->selectAndLoadSymbols(); | ->selectAndLoadSymbols(); | ||||
| $groups = array(); | $groups = array(); | ||||
| foreach ($symbols as $symbol) { | foreach ($symbols as $symbol) { | ||||
| if ($external_only && $symbol['library'] == 'phabricator') { | if ($external_only && $symbol['library'] == 'phabricator') { | ||||
| continue; | continue; | ||||
| } | } | ||||
| $obj = newv($symbol['name'], array()); | $obj = newv($symbol['name'], array()); | ||||
| $key = $obj->getKey(); | $key = $obj->getKey(); | ||||
| if (isset($groups[$key])) { | if (isset($groups[$key])) { | ||||
| $pclass = get_class($groups[$key]); | $pclass = get_class($groups[$key]); | ||||
| $nclass = $symbol['name']; | $nclass = $symbol['name']; | ||||
| throw new Exception( | throw new Exception( | ||||
| "Multiple PhabricatorApplicationConfigOptions subclasses have the ". | pht( | ||||
| "same key ('{$key}'): {$pclass}, {$nclass}."); | "Multiple %s subclasses have the same key ('%s'): %s, %s.", | ||||
| __CLASS__, | |||||
| $key, | |||||
| $pclass, | |||||
| $nclass)); | |||||
| } | } | ||||
| $groups[$key] = $obj; | $groups[$key] = $obj; | ||||
| } | } | ||||
| return $groups; | return $groups; | ||||
| } | } | ||||
| final public static function loadAllOptions($external_only = false) { | final public static function loadAllOptions($external_only = false) { | ||||
| $groups = self::loadAll($external_only); | $groups = self::loadAll($external_only); | ||||
| $options = array(); | $options = array(); | ||||
| foreach ($groups as $group) { | foreach ($groups as $group) { | ||||
| foreach ($group->getOptions() as $option) { | foreach ($group->getOptions() as $option) { | ||||
| $key = $option->getKey(); | $key = $option->getKey(); | ||||
| if (isset($options[$key])) { | if (isset($options[$key])) { | ||||
| throw new Exception( | throw new Exception( | ||||
| "Mulitple PhabricatorApplicationConfigOptions subclasses contain ". | pht( | ||||
| "an option named '{$key}'!"); | "Mulitple % subclasses contain an option named '%s'!", | ||||
| __CLASS__, | |||||
| $key)); | |||||
| } | } | ||||
| $options[$key] = $option; | $options[$key] = $option; | ||||
| } | } | ||||
| } | } | ||||
| return $options; | return $options; | ||||
| } | } | ||||
| Show All 9 Lines | |||||