25use Wikimedia\Assert\Assert;
26use Wikimedia\Services\SalvageableService;
36 private $configFactory;
39 private $configItems = [
48 $this->configFactory = $configFactory;
58 public function has( $name, $alsoPrivate =
false ) {
59 return isset( $this->configItems[
'public'][$name] ) ||
60 ( $alsoPrivate && isset( $this->configItems[
'private'][$name] ) );
71 public function get( $name ) {
72 if ( !$this->
has( $name,
true ) ) {
73 throw new ConfigException(
'The configuration option ' . $name .
' does not exist.' );
76 return $this->configItems[
'public'][$name] ?? $this->configItems[
'private'][$name];
90 return array_merge( $this->configItems[
'private'], $this->configItems[
'public'] );
99 return $this->configItems[
'public'];
111 $config = $this->
get( $name );
112 if ( isset( $config[
'descriptionmsg'] ) ) {
113 return wfMessage( $config[
'descriptionmsg'] )->escaped();
115 if ( isset( $config[
'description'] ) ) {
116 return htmlspecialchars( $config[
'description'] );
136 public function add( $name, array $config ) {
137 if ( $this->
has( $name ) ) {
139 'does already exist. It is provided by: ' .
140 $this->
get( $name )[
'providedby'] );
142 if ( isset( $config[
'public'] ) && $config[
'public'] ) {
143 $this->configItems[
'public'][$name] = $config;
145 $this->configItems[
'private'][$name] = $config;
156 public function isEmpty( $includePrivate =
false ) {
157 if ( $includePrivate ) {
158 return empty( $this->configItems[
'private'] ) &&
159 empty( $this->configItems[
'public'] );
161 return empty( $this->configItems[
'public'] );
173 public function salvage( SalvageableService $other ) {
174 Assert::parameterType( self::class, $other,
'$other' );
176 '@phan-var self $other';
178 foreach ( $other->configItems[
'public'] as $name => $otherConfig ) {
179 if ( isset( $this->configItems[
'public'][$name] ) ) {
183 $this->
add( $name, $otherConfig );
185 foreach ( $other->configItems[
'private'] as $name => $otherConfig ) {
186 if ( isset( $this->configItems[
'private'][$name] ) ) {
190 $this->
add( $name, $otherConfig );
194 $other->configItems = [];
wfMessage( $key,... $params)
This is the function for getting translated interface messages.