mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-30 18:52:42 +01:00
19b2c3d3d0
Summary: Currently, we have a configuration stack for unit tests, but they're built in to `PhabricatorEnv`. Pull them out and formalize them, so we can add more configuration sources (e.g., database). Test Plan: Ran unit tests, web requests, scripts. This code had fairly good existing test coverage. Reviewers: btrahan, vrana Reviewed By: btrahan CC: aran Maniphest Tasks: T2223, T2221 Differential Revision: https://secure.phabricator.com/D4284
36 lines
688 B
PHP
36 lines
688 B
PHP
<?php
|
|
|
|
final class PhabricatorConfigDictionarySource
|
|
extends PhabricatorConfigSource {
|
|
|
|
private $dictionary;
|
|
|
|
public function __construct(array $dictionary) {
|
|
$this->dictionary = $dictionary;
|
|
}
|
|
|
|
public function getAllKeys() {
|
|
return $this->dictionary;
|
|
}
|
|
|
|
public function getKeys(array $keys) {
|
|
return array_select_keys($this->dictionary, $keys);
|
|
}
|
|
|
|
public function canWrite() {
|
|
return true;
|
|
}
|
|
|
|
public function setKeys(array $keys) {
|
|
$this->dictionary = $keys + $this->dictionary;
|
|
return $this;
|
|
}
|
|
|
|
public function deleteKeys(array $keys) {
|
|
foreach ($keys as $key) {
|
|
unset($this->dictionary[$key]);
|
|
}
|
|
return $keys;
|
|
}
|
|
|
|
}
|