11use Wikimedia\Assert\Assert;
12use Wikimedia\Services\SalvageableService;
22 private $configItems = [
39 public function has( $name, $alsoPrivate =
false ) {
40 return isset( $this->configItems[
'public'][$name] ) ||
41 ( $alsoPrivate && isset( $this->configItems[
'private'][$name] ) );
52 public function get( $name ) {
53 if ( !$this->
has( $name,
true ) ) {
54 throw new ConfigException(
'The configuration option ' . $name .
' does not exist.' );
57 return $this->configItems[
'public'][$name] ?? $this->configItems[
'private'][$name];
71 return array_merge( $this->configItems[
'private'], $this->configItems[
'public'] );
80 return $this->configItems[
'public'];
92 $config = $this->
get( $name );
93 if ( isset( $config[
'descriptionmsg'] ) ) {
94 return wfMessage( $config[
'descriptionmsg'] )->escaped();
96 if ( isset( $config[
'description'] ) ) {
97 return htmlspecialchars( $config[
'description'] );
115 public function add( $name, array $config ) {
116 if ( $this->
has( $name ) ) {
118 'does already exist.' );
120 if ( isset( $config[
'public'] ) && $config[
'public'] ) {
121 $this->configItems[
'public'][$name] = $config;
123 $this->configItems[
'private'][$name] = $config;
134 public function isEmpty( $includePrivate =
false ) {
135 if ( $includePrivate ) {
136 return empty( $this->configItems[
'private'] ) &&
137 empty( $this->configItems[
'public'] );
139 return empty( $this->configItems[
'public'] );
151 public function salvage( SalvageableService $other ) {
152 Assert::parameterType( self::class, $other,
'$other' );
154 '@phan-var self $other';
156 foreach ( $other->configItems[
'public'] as $name => $otherConfig ) {
157 if ( isset( $this->configItems[
'public'][$name] ) ) {
161 $this->
add( $name, $otherConfig );
163 foreach ( $other->configItems[
'private'] as $name => $otherConfig ) {
164 if ( isset( $this->configItems[
'private'][$name] ) ) {
168 $this->
add( $name, $otherConfig );
172 $other->configItems = [];
wfMessage( $key,... $params)
This is the function for getting translated interface messages.