MediaWiki
REL1_23
|
00001 <?php 00028 class GlobalVarConfig implements Config { 00029 00034 private $prefix; 00035 00040 public static function newInstance() { 00041 return new GlobalVarConfig(); 00042 } 00043 00044 public function __construct( $prefix = 'wg' ) { 00045 $this->prefix = $prefix; 00046 } 00047 00051 public function get( $name ) { 00052 return $this->getWithPrefix( $this->prefix, $name ); 00053 } 00054 00058 public function set( $name, $value ) { 00059 $this->setWithPrefix( $this->prefix, $name, $value ); 00060 } 00061 00070 protected function getWithPrefix( $prefix, $name ) { 00071 $var = $prefix . $name; 00072 if ( !array_key_exists( $var, $GLOBALS ) ) { 00073 throw new ConfigException( __METHOD__ . ": undefined variable: '$var'" ); 00074 } 00075 return $GLOBALS[ $var ]; 00076 } 00077 00085 protected function setWithPrefix( $prefix, $name, $value ) { 00086 $GLOBALS[ $prefix . $name ] = $value; 00087 } 00088 }