25use Wikimedia\Assert\Assert;
26use Wikimedia\Services\SalvageableService;
36 private $configFactory;
39 private $configItems = [
45 $this->configFactory = $configFactory;
55 public function has( $name, $alsoPrivate =
false ) {
56 return isset( $this->configItems[
'public'][$name] ) ||
57 ( $alsoPrivate && isset( $this->configItems[
'private'][$name] ) );
68 public function get( $name ) {
69 if ( !$this->
has( $name,
true ) ) {
70 throw new ConfigException(
'The configuration option ' . $name .
' does not exist.' );
73 return $this->configItems[
'public'][$name] ?? $this->configItems[
'private'][$name];
87 return array_merge( $this->configItems[
'private'], $this->configItems[
'public'] );
96 return $this->configItems[
'public'];
108 $config = $this->
get( $name );
109 if ( isset( $config[
'descriptionmsg'] ) ) {
110 return wfMessage( $config[
'descriptionmsg'] )->escaped();
112 if ( isset( $config[
'description'] ) ) {
113 return htmlspecialchars( $config[
'description'] );
133 public function add( $name, array $config ) {
134 if ( $this->
has( $name ) ) {
136 'does already exist. It is provided by: ' .
137 $this->
get( $name )[
'providedby'] );
139 if ( isset( $config[
'public'] ) && $config[
'public'] ) {
140 $this->configItems[
'public'][$name] = $config;
142 $this->configItems[
'private'][$name] = $config;
153 public function isEmpty( $includePrivate =
false ) {
154 if ( $includePrivate ) {
155 return empty( $this->configItems[
'private'] ) &&
156 empty( $this->configItems[
'public'] );
158 return empty( $this->configItems[
'public'] );
170 public function salvage( SalvageableService $other ) {
171 Assert::parameterType( self::class, $other,
'$other' );
173 '@phan-var self $other';
175 foreach ( $other->configItems[
'public'] as $name => $otherConfig ) {
176 if ( isset( $this->configItems[
'public'][$name] ) ) {
180 $this->
add( $name, $otherConfig );
182 foreach ( $other->configItems[
'private'] as $name => $otherConfig ) {
183 if ( isset( $this->configItems[
'private'][$name] ) ) {
187 $this->
add( $name, $otherConfig );
191 $other->configItems = [];
wfMessage( $key,... $params)
This is the function for getting translated interface messages.