Something went wrong. Try again.
@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
Something went wrong. Try again.
1.8 kB · 80 lines
PHP
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081<?php
/** * Configuration source which reads from a stack of other configuration * sources. * * This source is writable if any source in the stack is writable. Writes happen * to the first writable source only. */final class PhabricatorConfigStackSource extends PhabricatorConfigSource {
private $stack = array();
public function pushSource(PhabricatorConfigSource $source) { array_unshift($this->stack, $source); return $this; }
public function popSource() { if (empty($this->stack)) { throw new Exception(pht('Popping an empty %s!', self::class)); } return array_shift($this->stack); }
public function getStack() { return $this->stack; }
public function getKeys(array $keys) { $result = array(); foreach ($this->stack as $source) { $result = $result + $source->getKeys($keys); } return $result; }
public function getAllKeys() { $result = array(); foreach ($this->stack as $source) { $result = $result + $source->getAllKeys(); } return $result; }
public function canWrite() { foreach ($this->stack as $source) { if ($source->canWrite()) { return true; } } return false; }
public function setKeys(array $keys) { foreach ($this->stack as $source) { if ($source->canWrite()) { $source->setKeys($keys); return; } }
// We can't write; this will throw an appropriate exception. parent::setKeys($keys); }
public function deleteKeys(array $keys) { foreach ($this->stack as $source) { if ($source->canWrite()) { $source->deleteKeys($keys); return; } }
// We can't write; this will throw an appropriate exception. parent::deleteKeys($keys); }
}