미디어위키 GlobalVarConfig

1 개요[ | ]

미디어위키 GlobalVarConfig
<?php
class GlobalVarConfig implements Config {

    private $prefix;

    public static function newInstance() {
        return new GlobalVarConfig();
    }

    public function __construct( $prefix = 'wg' ) {
        $this->prefix = $prefix;
    }

    public function get( $name ) {
        if ( !$this->has( $name ) ) {
            throw new ConfigException( __METHOD__ . ": undefined option: '$name'" );
        }
        return $this->getWithPrefix( $this->prefix, $name );
    }

    public function has( $name ) {
        return $this->hasWithPrefix( $this->prefix, $name );
    }

    protected function getWithPrefix( $prefix, $name ) {
        return $GLOBALS[$prefix . $name];
    }

    protected function hasWithPrefix( $prefix, $name ) {
        $var = $prefix . $name;
        return array_key_exists( $var, $GLOBALS );
    }
}

2 같이 보기[ | ]

3 참고[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}