Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4132989
TemplateDataStatus.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
TemplateDataStatus.php
View Options
<?php
namespace
MediaWiki\Extension\TemplateData
;
use
MediaWiki\Status\Status
;
/**
* @license GPL-2.0-or-later
*/
class
TemplateDataStatus
{
/**
* @param Status $status
* @return array contains StatusValue ok and errors fields (does not serialize value)
*/
public
static
function
jsonSerialize
(
Status
$status
):
array
{
if
(
$status
->
isOK
()
)
{
return
[
'ok'
=>
true
];
}
[
$errorsOnlyStatus
,
$warningsOnlyStatus
]
=
$status
->
splitByErrorType
();
// note that non-scalar values are not supported in errors or warnings
return
[
'ok'
=>
false
,
'errors'
=>
$errorsOnlyStatus
->
getErrors
(),
'warnings'
=>
$warningsOnlyStatus
->
getErrors
()
];
}
/**
* @param Status|array|null $json contains StatusValue ok and errors fields (does not serialize value)
* @return Status|null
*/
public
static
function
newFromJson
(
$json
):
?
Status
{
if
(
!
is_array
(
$json
)
)
{
return
$json
;
}
if
(
$json
[
'ok'
]
)
{
return
Status
::
newGood
();
}
$status
=
new
Status
();
foreach
(
$json
[
'errors'
]
as
$error
)
{
$status
->
fatal
(
$error
[
'message'
],
...
$error
[
'params'
]
);
}
foreach
(
$json
[
'warnings'
]
as
$warning
)
{
$status
->
warning
(
$warning
[
'message'
],
...
$warning
[
'params'
]
);
}
return
$status
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Wed, Aug 19, 11:55 (3 w, 2 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
6e/9c/0273e95eaae2887b6b5b663dc06c
Default Alt Text
TemplateDataStatus.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment