1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-23 23:32:40 +01:00
phorge-phorge/src/infrastructure/env/PhabricatorConfigDictionarySource.php
epriestley 19b2c3d3d0 Formalize configuration sources and source stacks
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
2012-12-25 06:44:29 -08:00

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;
}
}