Path: blob/master/src/infrastructure/env/PhabricatorConfigStackSource.php
12241 views
<?php12/**3* Configuration source which reads from a stack of other configuration4* sources.5*6* This source is writable if any source in the stack is writable. Writes happen7* to the first writable source only.8*/9final class PhabricatorConfigStackSource10extends PhabricatorConfigSource {1112private $stack = array();1314public function pushSource(PhabricatorConfigSource $source) {15array_unshift($this->stack, $source);16return $this;17}1819public function popSource() {20if (empty($this->stack)) {21throw new Exception(pht('Popping an empty %s!', __CLASS__));22}23return array_shift($this->stack);24}2526public function getStack() {27return $this->stack;28}2930public function getKeys(array $keys) {31$result = array();32foreach ($this->stack as $source) {33$result = $result + $source->getKeys($keys);34}35return $result;36}3738public function getAllKeys() {39$result = array();40foreach ($this->stack as $source) {41$result = $result + $source->getAllKeys();42}43return $result;44}4546public function canWrite() {47foreach ($this->stack as $source) {48if ($source->canWrite()) {49return true;50}51}52return false;53}5455public function setKeys(array $keys) {56foreach ($this->stack as $source) {57if ($source->canWrite()) {58$source->setKeys($keys);59return;60}61}6263// We can't write; this will throw an appropriate exception.64parent::setKeys($keys);65}6667public function deleteKeys(array $keys) {68foreach ($this->stack as $source) {69if ($source->canWrite()) {70$source->deleteKeys($keys);71return;72}73}7475// We can't write; this will throw an appropriate exception.76parent::deleteKeys($keys);77}7879}808182