[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class PhabricatorLipsumGenerateWorkflow 4 extends PhabricatorLipsumManagementWorkflow { 5 6 protected function didConstruct() { 7 $this 8 ->setName('generate') 9 ->setExamples('**generate**') 10 ->setSynopsis('Generate some lipsum.') 11 ->setArguments( 12 array( 13 array( 14 'name' => 'args', 15 'wildcard' => true, 16 ), 17 )); 18 } 19 20 public function execute(PhutilArgumentParser $args) { 21 $supported_types = id(new PhutilSymbolLoader()) 22 ->setAncestorClass('PhabricatorTestDataGenerator') 23 ->loadObjects(); 24 echo "These are the types of data you can generate:\n"; 25 foreach (array_keys($supported_types) as $typetmp) { 26 echo "\t".$typetmp."\n"; 27 } 28 echo "\n"; 29 $prompt = 'Are you sure you want to generate lots of test data?'; 30 if (!phutil_console_confirm($prompt, $default_no = true)) { 31 return; 32 } 33 $argv = $args->getArg('args'); 34 if (count($argv) == 0 || 35 (count($argv) == 1 && $argv[0] == 'all')) { 36 $this->infinitelyGenerate($supported_types); 37 } else { 38 $new_supported_types = array(); 39 for ($i = 0; $i < count($argv);$i++) { 40 $arg = $argv[$i]; 41 if (array_key_exists($arg, $supported_types)) { 42 $new_supported_types[$arg] = $supported_types[$arg]; 43 } else { 44 echo "The type ".$arg." is not supported by the lipsum generator.\n"; 45 } 46 } 47 $this->infinitelyGenerate($new_supported_types); 48 } 49 echo "None of the input types were supported.\n"; 50 echo "The supported types are:\n"; 51 echo implode("\n", array_keys($supported_types)); 52 } 53 54 protected function infinitelyGenerate(array $supported_types) { 55 if (count($supported_types) == 0) { 56 echo "None of the input types were supported.\n"; 57 return; 58 } 59 echo 'GENERATING: '; 60 echo strtoupper(implode(' , ', array_keys($supported_types))); 61 echo "\n"; 62 while (true) { 63 $type = $supported_types[array_rand($supported_types)]; 64 $admin = $this->getViewer(); 65 66 $taskgen = newv($type, array()); 67 $object = $taskgen->generate(); 68 $handle = id(new PhabricatorHandleQuery()) 69 ->setViewer($admin) 70 ->withPHIDs(array($object->getPHID())) 71 ->executeOne(); 72 echo "Generated ".$handle->getTypeName().": ". 73 $handle->getFullName()."\n"; 74 75 usleep(200000); 76 } 77 } 78 79 }
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 |