mirror of
https://we.phorge.it/source/phorge.git
synced 2025-02-21 03:08:40 +01:00
Summary: `pht`ize a whole bunch of strings in rP. Test Plan: Intense eyeballing. Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: hach-que, Korvin, epriestley Differential Revision: https://secure.phabricator.com/D12797
50 lines
1.2 KiB
PHP
50 lines
1.2 KiB
PHP
<?php
|
|
|
|
final class PhabricatorConfigLocalSource extends PhabricatorConfigProxySource {
|
|
|
|
public function __construct() {
|
|
$config = $this->loadConfig();
|
|
$this->setSource(new PhabricatorConfigDictionarySource($config));
|
|
}
|
|
|
|
public function setKeys(array $keys) {
|
|
$result = parent::setKeys($keys);
|
|
$this->saveConfig();
|
|
return $result;
|
|
}
|
|
|
|
public function deleteKeys(array $keys) {
|
|
$result = parent::deleteKeys($keys);
|
|
$this->saveConfig();
|
|
return parent::deleteKeys($keys);
|
|
}
|
|
|
|
private function loadConfig() {
|
|
$path = $this->getConfigPath();
|
|
if (@file_exists($path)) {
|
|
$data = @file_get_contents($path);
|
|
if ($data) {
|
|
$data = json_decode($data, true);
|
|
if (is_array($data)) {
|
|
return $data;
|
|
}
|
|
}
|
|
}
|
|
|
|
return array();
|
|
}
|
|
|
|
private function saveConfig() {
|
|
$config = $this->getSource()->getAllKeys();
|
|
$json = new PhutilJSON();
|
|
$data = $json->encodeFormatted($config);
|
|
Filesystem::writeFile($this->getConfigPath(), $data);
|
|
}
|
|
|
|
private function getConfigPath() {
|
|
$root = dirname(phutil_get_library_root('phabricator'));
|
|
$path = $root.'/conf/local/local.json';
|
|
return $path;
|
|
}
|
|
|
|
}
|