[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class PhabricatorConfigManagementDeleteWorkflow 4 extends PhabricatorConfigManagementWorkflow { 5 6 protected function didConstruct() { 7 $this 8 ->setName('delete') 9 ->setExamples('**delete** __key__') 10 ->setSynopsis(pht('Delete a local configuration value.')) 11 ->setArguments( 12 array( 13 array( 14 'name' => 'database', 15 'help' => pht('Delete configuration in the database instead of '. 16 'in local configuration.'), 17 ), 18 array( 19 'name' => 'args', 20 'wildcard' => true, 21 ), 22 )); 23 } 24 25 public function execute(PhutilArgumentParser $args) { 26 $console = PhutilConsole::getConsole(); 27 28 $argv = $args->getArg('args'); 29 if (count($argv) == 0) { 30 throw new PhutilArgumentUsageException(pht( 31 'Specify a configuration key to delete.')); 32 } 33 34 $key = $argv[0]; 35 36 if (count($argv) > 1) { 37 throw new PhutilArgumentUsageException(pht( 38 'Too many arguments: expected one key.')); 39 } 40 41 42 $use_database = $args->getArg('database'); 43 if ($use_database) { 44 $config = new PhabricatorConfigDatabaseSource('default'); 45 $config_type = 'database'; 46 } else { 47 $config = new PhabricatorConfigLocalSource(); 48 $config_type = 'local'; 49 } 50 $values = $config->getKeys(array($key)); 51 if (!$values) { 52 throw new PhutilArgumentUsageException(pht( 53 "Configuration key '%s' is not set in %s configuration!", 54 $key, 55 $config_type)); 56 } 57 58 if ($use_database) { 59 $config_entry = id(new PhabricatorConfigOption()) 60 ->loadOneWhere( 61 'namespace = %s and key = %s', 62 'default', 63 $key); 64 PhabricatorConfigEditor::deleteConfig( 65 $this->getViewer(), 66 $config_entry, 67 PhabricatorContentSource::newConsoleSource()); 68 } else { 69 $config->deleteKeys(array($key)); 70 } 71 72 $console->writeOut( 73 pht("Deleted '%s' from %s configuration.", $key, $config_type)."\n"); 74 } 75 76 }
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 |