Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F5969673
ConfigBuilderBase.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
ConfigBuilderBase.php
View Options
<?php
namespace
MediaWiki\Settings\Config
;
abstract
class
ConfigBuilderBase
implements
ConfigBuilder
{
abstract
protected
function
has
(
string
$key
):
bool
;
abstract
protected
function
update
(
string
$key
,
$value
);
/**
* @inheritDoc
*/
public
function
set
(
string
$key
,
$newValue
,
?
MergeStrategy
$mergeStrategy
=
null
):
ConfigBuilder
{
if
(
$mergeStrategy
&&
$this
->
has
(
$key
)
&&
is_array
(
$newValue
)
)
{
$oldValue
=
$this
->
get
(
$key
);
if
(
$oldValue
&&
is_array
(
$oldValue
)
)
{
$newValue
=
$mergeStrategy
->
merge
(
$oldValue
,
$newValue
);
}
}
$this
->
update
(
$key
,
$newValue
);
return
$this
;
}
/**
* @inheritDoc
*/
public
function
setMulti
(
array
$values
,
array
$mergeStrategies
=
[]
):
ConfigBuilder
{
foreach
(
$values
as
$key
=>
$value
)
{
$this
->
set
(
$key
,
$value
,
$mergeStrategies
[
$key
]
??
null
);
}
return
$this
;
}
/**
* @inheritDoc
*/
public
function
setDefault
(
string
$key
,
$defaultValue
,
?
MergeStrategy
$mergeStrategy
=
null
):
ConfigBuilder
{
if
(
$this
->
has
(
$key
)
)
{
if
(
$mergeStrategy
&&
$defaultValue
&&
is_array
(
$defaultValue
)
)
{
$customValue
=
$this
->
get
(
$key
);
if
(
is_array
(
$customValue
)
)
{
$newValue
=
$mergeStrategy
->
merge
(
$defaultValue
,
$customValue
);
$this
->
update
(
$key
,
$newValue
);
}
}
}
else
{
$this
->
update
(
$key
,
$defaultValue
);
}
return
$this
;
}
/**
* @inheritDoc
*/
public
function
setMultiDefault
(
array
$defaults
,
array
$mergeStrategies
):
ConfigBuilder
{
foreach
(
$defaults
as
$key
=>
$defaultValue
)
{
$this
->
setDefault
(
$key
,
$defaultValue
,
$mergeStrategies
[
$key
]
??
null
);
}
return
$this
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, Oct 3, 13:55 (19 h, 54 m ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
9d/d5/4e3c5415203a5c5917bafcd3588a
Default Alt Text
ConfigBuilderBase.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment