[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class PhabricatorConfigLocalSource 4 extends PhabricatorConfigProxySource { 5 6 public function __construct() { 7 $config = $this->loadConfig(); 8 $this->setSource(new PhabricatorConfigDictionarySource($config)); 9 } 10 11 public function setKeys(array $keys) { 12 $result = parent::setKeys($keys); 13 $this->saveConfig(); 14 return $result; 15 } 16 17 public function deleteKeys(array $keys) { 18 $result = parent::deleteKeys($keys); 19 $this->saveConfig(); 20 return parent::deleteKeys($keys); 21 } 22 23 private function loadConfig() { 24 $path = $this->getConfigPath(); 25 if (@file_exists($path)) { 26 $data = @file_get_contents($path); 27 if ($data) { 28 $data = json_decode($data, true); 29 if (is_array($data)) { 30 return $data; 31 } 32 } 33 } 34 35 return array(); 36 } 37 38 private function saveConfig() { 39 $config = $this->getSource()->getAllKeys(); 40 $json = new PhutilJSON(); 41 $data = $json->encodeFormatted($config); 42 Filesystem::writeFile($this->getConfigPath(), $data); 43 } 44 45 private function getConfigPath() { 46 $root = dirname(phutil_get_library_root('phabricator')); 47 $path = $root.'/conf/local/local.json'; 48 return $path; 49 } 50 51 }
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 |