[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class PhabricatorConfigManagementGetWorkflow 4 extends PhabricatorConfigManagementWorkflow { 5 6 protected function didConstruct() { 7 $this 8 ->setName('get') 9 ->setExamples('**get** __key__') 10 ->setSynopsis('Get a local configuration value.') 11 ->setArguments( 12 array( 13 array( 14 'name' => 'args', 15 'wildcard' => true, 16 ), 17 )); 18 } 19 20 public function execute(PhutilArgumentParser $args) { 21 $console = PhutilConsole::getConsole(); 22 23 $argv = $args->getArg('args'); 24 if (count($argv) == 0) { 25 throw new PhutilArgumentUsageException( 26 'Specify a configuration key to get.'); 27 } 28 29 $key = $argv[0]; 30 31 if (count($argv) > 1) { 32 throw new PhutilArgumentUsageException( 33 'Too many arguments: expected one key.'); 34 } 35 36 $options = PhabricatorApplicationConfigOptions::loadAllOptions(); 37 if (empty($options[$key])) { 38 throw new PhutilArgumentUsageException( 39 "No such configuration key '{$key}'! Use `config list` to list all ". 40 "keys."); 41 } 42 43 $values = array(); 44 $config = new PhabricatorConfigLocalSource(); 45 $local_value = $config->getKeys(array($key)); 46 if (empty($local_value)) { 47 $values['local'] = array( 48 'key' => $key, 49 'value' => null, 50 'status' => 'unset', 51 'errorInfo' => null, 52 ); 53 } else { 54 $values['local'] = array( 55 'key' => $key, 56 'value' => reset($local_value), 57 'status' => 'set', 58 'errorInfo' => null, 59 ); 60 } 61 62 try { 63 $database_config = new PhabricatorConfigDatabaseSource('default'); 64 $database_value = $database_config->getKeys(array($key)); 65 if (empty($database_value)) { 66 $values['database'] = array( 67 'key' => $key, 68 'value' => null, 69 'status' => 'unset', 70 'errorInfo' => null, 71 ); 72 } else { 73 $values['database'] = array( 74 'key' => $key, 75 'value' => reset($database_value), 76 'status' => 'set', 77 'errorInfo' => null, 78 ); 79 } 80 } catch (Exception $e) { 81 $values['database'] = array( 82 'key' => $key, 83 'value' => null, 84 'status' => 'error', 85 'errorInfo' => pht('Database source is not configured properly'), 86 ); 87 } 88 89 $result = array(); 90 foreach ($values as $source => $value) { 91 $result[] = array( 92 'key' => $value['key'], 93 'source' => $source, 94 'value' => $value['value'], 95 'status' => $value['status'], 96 'errorInfo' => $value['errorInfo'], 97 ); 98 } 99 $result = array( 100 'config' => $result, 101 ); 102 103 $json = new PhutilJSON(); 104 $console->writeOut($json->encodeFormatted($result)); 105 } 106 107 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |