[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 abstract class DivinerWorkflow extends PhabricatorManagementWorkflow { 4 5 private $config; 6 private $bookConfigPath; 7 8 public function getBookConfigPath() { 9 return $this->bookConfigPath; 10 } 11 12 protected function getConfig($key, $default = null) { 13 return idx($this->config, $key, $default); 14 } 15 16 protected function getAllConfig() { 17 return $this->config; 18 } 19 20 protected function readBookConfiguration($book_path) { 21 if ($book_path === null) { 22 throw new PhutilArgumentUsageException( 23 'Specify a Diviner book configuration file with --book.'); 24 } 25 26 $book_data = Filesystem::readFile($book_path); 27 $book = json_decode($book_data, true); 28 if (!is_array($book)) { 29 throw new PhutilArgumentUsageException( 30 "Book configuration '{$book_path}' is not in JSON format."); 31 } 32 33 PhutilTypeSpec::checkMap( 34 $book, 35 array( 36 'name' => 'string', 37 'title' => 'optional string', 38 'short' => 'optional string', 39 'preface' => 'optional string', 40 'root' => 'optional string', 41 'uri.source' => 'optional string', 42 'rules' => 'optional map<regex, string>', 43 'exclude' => 'optional regex|list<regex>', 44 'groups' => 'optional map<string, map<string, wild>>', 45 )); 46 47 // If the book specifies a "root", resolve it; otherwise, use the directory 48 // the book configuration file lives in. 49 $full_path = dirname(Filesystem::resolvePath($book_path)); 50 if (empty($book['root'])) { 51 $book['root'] = '.'; 52 } 53 $book['root'] = Filesystem::resolvePath($book['root'], $full_path); 54 55 if (!preg_match('/^[a-z][a-z-]*\z/', $book['name'])) { 56 $name = $book['name']; 57 throw new PhutilArgumentUsageException( 58 "Book configuration '{$book_path}' has name '{$name}', but book names ". 59 "must include only lowercase letters and hyphens."); 60 } 61 62 foreach (idx($book, 'groups', array()) as $group) { 63 PhutilTypeSpec::checkmap( 64 $group, 65 array( 66 'name' => 'string', 67 'include' => 'optional regex|list<regex>', 68 )); 69 70 } 71 72 $this->bookConfigPath = $book_path; 73 $this->config = $book; 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 |