Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F1427543
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, May 16, 14:45 (21 h, 32 m)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
69/24/9e10c591197d096c21f248b5c5f5
Default Alt Text
ConfigBuilderBase.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment